Socket object
Property | Description | Access | Type |
---|---|---|---|
Socket.blocking | Get/set socket blocking mode | readwrite | boolean |
Socket.port | Ges the Socket port number | readonly | number |
Socket.ip | Get the Socket IP address | readonly | string |
Socket.nodelay | Get/Set the TCP_NODELAY option | readwrite | boolean |
Socket.family | Get the Socket address family | readonly | string |
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 |
Method | Description | Return value |
---|---|---|
Socket.constructor() | Socket object constuctor | Socket |
Socket:accept() | Accept an incoming connection | Socket | boolean | Task |
Socket:close() | Close the connection | - |
Socket:connect() | Connect to a server | boolean | Task |
Socket:bind() | Bind and listen for incoming connections | boolean |
Socket:peek() | Peek for available bytes | number |
Socket:recv() | Receives data from the socket | Buffer | boolean | Task | nil |
Socket:send() | Send data to the Socket | boolean | Task | nil |
Socket:shutdown() | Shutdowns the socket connection | - |
Socket:starttls() | Start TLS encryption | boolean |