Socket object
The Socket object sends and receives data over network connections
| Property | Description | Access | Type |
|---|---|---|---|
| Socket.blocking | Get/set socket blocking mode | readwrite | boolean |
| Socket.canread | Check if Socket is readable after a net.select() call | readonly | boolean |
| Socket.canwrite | Check if Socket is writable after a net.select() call | readonly | boolean |
| Socket.failed | Check if Socket is in error state after a net.select() call | readonly | boolean |
| Socket.family | Get the Socket address family | readonly | string |
| Socket.ip | Get the Socket IP address | readonly | string |
| Socket.nodelay | Get/Set the TCP_NODELAY option | readwrite | boolean |
| Socket.port | Ges the Socket port number | readonly | number |
| Methods | Description | Return value |
|---|---|---|
| Socket:accept() | Accept an incoming connection | |
| Socket:bind() | Bind and listen for incoming connections | boolean |
| Socket:close() | Close the connection | - |
| Socket:connect() | Connect to a server | |
| Socket:constructor() | Socket object constuctor | |
| Socket:peek() | Peek for available bytes | number |
| Socket:recv() | Receives data from the socket | |
| Socket:send() | Send data to the Socket | |
| Socket:shutdown() | Shutdowns the socket connection | - |
| Socket:starttls() | Start TLS encryption | boolean |