socket [object]
- methods
- bind - bind socket to port
- listen - wait for connection requests, return if successful
- accept - accept an incoming connection, retrieve connecting socket
- connect - connect to a remote address
- send - send data over socket
- sendto - send data to specified address over socket
- recv - receive data from socket
- recvfrom - receive connectionless data and sender address from socket
- shutdown - shut down socket access (partially or fully)
- close - close socket, disabling further operations
- getpeername - get hostname of connected device
- read-only properties
- [int] error - the last error code specifically for the socket
- write-only properties
- [bool] blocking - whether the socket is blocking
- read/write properties
- [bool] broadcast - whether the socket has broadcasting capabilities (applies to UDP sockets only)
- [bool] reuse_addr - whether to reuse addresses (ports) when binding the socket
- [real] send_timeout - timeout in seconds for send / sendto functions
- [real] recv_timeout - timeout in seconds for recv / recvfrom functions
- other features:
- tostring = "socket"
- tobool = whether the socket is valid (not closed yet)
- GC-safe
- type identification (returns the string "socket")