Socket functions.
Socket default timeout value
Socket type definition
Invalid socket handle
Domain type
DOMAIN_MISSING -
DOMAIN_IPV4 -
DOMAIN_IPV6 -
DOMAIN_UNKNOWN -
Socket type
TYPE_STREAM -
TYPE_DGRAM -
Network protocol
PROTOCOL_TCP -
PROTOCOL_UDP -
Socket shutdown type
SHUTDOWNTYPE_READ -
SHUTDOWNTYPE_WRITE -
SHUTDOWNTYPE_READWRITE -
Socket result
RESULT_OK - 0
RESULT_ACCES - -1
RESULT_AFNOSUPPORT - -2
RESULT_WOULDBLOCK - -3
RESULT_BADF - -4
RESULT_CONNRESET - -5
RESULT_DESTADDRREQ - -6
RESULT_FAULT - -7
RESULT_HOSTUNREACH - -8
RESULT_INTR - -9
RESULT_INVAL - -10
RESULT_ISCONN - -11
RESULT_MFILE - -12
RESULT_MSGSIZE - -13
RESULT_NETDOWN - -14
RESULT_NETUNREACH - -15
RESULT_NOBUFS - -17
RESULT_NOTCONN - -20
RESULT_NOTSOCK - -22
RESULT_OPNOTSUPP - -23
RESULT_PIPE - -24
RESULT_PROTONOSUPPORT - -25
RESULT_PROTOTYPE - -26
RESULT_TIMEDOUT - -27
RESULT_ADDRNOTAVAIL - -28
RESULT_CONNREFUSED - -29
RESULT_ADDRINUSE - -30
RESULT_CONNABORTED - -31
RESULT_INPROGRESS - -32
RESULT_HOST_NOT_FOUND - -100
RESULT_TRY_AGAIN - -101
RESULT_NO_RECOVERY - -102
RESULT_NO_DATA - -103
RESULT_UNKNOWN - -1000
Network addresses were previously represented as an uint32_t, but in order to support IPv6 the internal representation was changed to a struct.
Create a new socket. Corresponds to BSD socket function socket().
type - Socket type
protocol - Protocol
socket - Pointer to socket
- RESULT_OK on succcess
Delete a socket. Corresponds to BSD socket function close()
socket - Socket to close
- RESULT_OK on success
Initiate a connection on a socket
socket - Socket to initiate connection on
address - Address to connect to
port - Port to connect to
- RESULT_OK on success
Shutdown part of a socket connection
socket - Socket to shutdown connection ow
how - Shutdown type
- RESULT_OK on success
Get underlying file descriptor
socket - socket to get fd for
- file-descriptor
Set reuse socket address option on socket. Socket option SO_REUSEADDR on most platforms
socket - Socket to set reuse address to
reuse - True if reuse
- RESULT_OK on success
Set broadcast address option on socket. Socket option SO_BROADCAST on most platforms.
socket - Socket to set reuse address to
broadcast - True if broadcast
- RESULT_OK on success
Set blocking option on a socket
socket - Socket to set blocking on
blocking - True to block
- RESULT_OK on success
Set TCP_NODELAY on socket
socket - Socket to set TCP_NODELAY on
no_delay - True for no delay
- RESULT_OK on success
Set TCP_QUICKACK on socket
socket - Socket to set TCP_QUICKACK on
use_quick_ack - False to disable quick ack
- RESULT_OK on success
Set socket send timeout
socket - socket
timeout - timeout in microseconds
- RESULT_OK on success
Set socket receive timeout
socket - socket
timeout - timeout in microseconds
- RESULT_OK on success
Send a message on a socket
socket - Socket to send a message on
buffer - Buffer to send
length - Length of buffer to send
sent_bytes[out] - Number of bytes sent (result)
- RESULT_OK on success
Receive data on a socket
socket - Socket to receive data on
buffer[out] - Buffer to receive to
length - Receive buffer length
received_bytes[out] - Number of received bytes (result)
- RESULT_OK on success
Get host by name
name - Hostname to resolve
address - Host address result
ipv4 - Whether or not to search for IPv4 addresses
ipv6 - Whether or not to search for IPv6 addresses
- RESULT_OK on success
Get host by name with timeout and cancelability
name - Hostname to resolve
address - Host address result
timeout - Timeout in microseconds
cancelflag - if non null and set, will abort the call
ipv4 - Whether or not to search for IPv4 addresses
ipv6 - Whether or not to search for IPv6 addresses
- RESULT_OK on success
Convert result value to string
result - Result to convert
- Result as string
Selector kind
SELECTOR_KIND_READ -
SELECTOR_KIND_WRITE -
SELECTOR_KIND_EXCEPT -
Selector
Clear selector for socket. Similar to FD_CLR
selector - Selector
selector_kind - Kind to clear
socket - Socket to clear
-
Set selector for socket. Similar to FD_SET
selector - Selector
selector_kind - Kind to clear
socket - Socket to set
-
Check if selector is set. Similar to FD_ISSET
selector - Selector
selector_kind - Selector kind
socket - Socket to check for
- True if set.
Clear selector (all kinds). Similar to FD_ZERO
selector - Selector
-
Select for pending data
selector - Selector
timeout - Timeout. For blocking pass -1. (microseconds)
- RESULT_OK on success