Socket

Socket functions.

SOCKET_TIMEOUT

Socket default timeout value

Socket default timeout value


Socket

Socket type definition

Socket type definition


INVALID_SOCKET_HANDLE

Invalid socket handle

Invalid socket handle


Domain

domain type

Domain type

MEMBERS

DOMAIN_MISSING -

DOMAIN_IPV4 -

DOMAIN_IPV6 -

DOMAIN_UNKNOWN -


Type

socket type

Socket type

MEMBERS

TYPE_STREAM -

TYPE_DGRAM -


Protocol

network protocol

Network protocol

MEMBERS

PROTOCOL_TCP -

PROTOCOL_UDP -


ShutdownType

socket shutdown type

Socket shutdown type

MEMBERS

SHUTDOWNTYPE_READ -

SHUTDOWNTYPE_WRITE -

SHUTDOWNTYPE_READWRITE -


Result

socket result

Socket result

MEMBERS

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


Address()

network address

Network addresses were previously represented as an uint32_t, but in order to support IPv6 the internal representation was changed to a struct.


New(type, protocol, socket)

create a socket

Create a new socket. Corresponds to BSD socket function socket().

PARAMETERS

type - Socket type

protocol - Protocol

socket - Pointer to socket

RETURN

- RESULT_OK on succcess


Delete(socket)

delete a socket

Delete a socket. Corresponds to BSD socket function close()

PARAMETERS

socket - Socket to close

RETURN

- RESULT_OK on success


Connect(socket, address, port)

make a connection

Initiate a connection on a socket

PARAMETERS

socket - Socket to initiate connection on

address - Address to connect to

port - Port to connect to

RETURN

- RESULT_OK on success


Shutdown(socket, how)

close socket

Shutdown part of a socket connection

PARAMETERS

socket - Socket to shutdown connection ow

how - Shutdown type

RETURN

- RESULT_OK on success


GetFD(socket)

get underlying file descriptor

Get underlying file descriptor

PARAMETERS

socket - socket to get fd for

RETURN

- file-descriptor


SetReuseAddress(socket, reuse)

Set reuse socket address option on socket. Socket ...

Set reuse socket address option on socket. Socket option SO_REUSEADDR on most platforms

PARAMETERS

socket - Socket to set reuse address to

reuse - True if reuse

RETURN

- RESULT_OK on success


SetBroadcast(socket, broadcast)

Set broadcast address option on socket. Socket opt...

Set broadcast address option on socket. Socket option SO_BROADCAST on most platforms.

PARAMETERS

socket - Socket to set reuse address to

broadcast - True if broadcast

RETURN

- RESULT_OK on success


SetBlocking(socket, blocking)

Set blocking option on a socket

Set blocking option on a socket

PARAMETERS

socket - Socket to set blocking on

blocking - True to block

RETURN

- RESULT_OK on success


SetNoDelay(socket, no_delay)

Set TCP_NODELAY on socket

Set TCP_NODELAY on socket

PARAMETERS

socket - Socket to set TCP_NODELAY on

no_delay - True for no delay

RETURN

- RESULT_OK on success


SetQuickAck(socket, use_quick_ack)

Set TCP_QUICKACK on socket

Set TCP_QUICKACK on socket

PARAMETERS

socket - Socket to set TCP_QUICKACK on

use_quick_ack - False to disable quick ack

RETURN

- RESULT_OK on success


SetSendTimeout(socket, timeout)

Set socket send timeout

Set socket send timeout

PARAMETERS

socket - socket

timeout - timeout in microseconds

RETURN

- RESULT_OK on success


SetReceiveTimeout(socket, timeout)

Set socket receive timeout

Set socket receive timeout

PARAMETERS

socket - socket

timeout - timeout in microseconds

RETURN

- RESULT_OK on success


Send(socket, buffer, length, sent_bytes[out])

Send a message on a socket

Send a message on a socket

PARAMETERS

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)

RETURN

- RESULT_OK on success


Receive(socket, buffer[out], length, received_bytes[out])

Receive data on a socket

Receive data on a socket

PARAMETERS

socket - Socket to receive data on

buffer[out] - Buffer to receive to

length - Receive buffer length

received_bytes[out] - Number of received bytes (result)

RETURN

- RESULT_OK on success


GetHostByName(name, address, ipv4, ipv6)

get host by name

Get host by name

PARAMETERS

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

RETURN

- RESULT_OK on success


GetHostByName(name, address, timeout, cancelflag, ipv4, ipv6)

get host by name with timeout and cancelability

Get host by name with timeout and cancelability

PARAMETERS

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

RETURN

- RESULT_OK on success


ResultToString(result)

Convert result value to string

Convert result value to string

PARAMETERS

result - Result to convert

RETURN

- Result as string


SelectorKind

Selector kind

Selector kind

MEMBERS

SELECTOR_KIND_READ -

SELECTOR_KIND_WRITE -

SELECTOR_KIND_EXCEPT -


Selector()

Selector

Selector


SelectorClear(selector, selector_kind, socket)

Clear selector for socket. Similar to FD_CLR

Clear selector for socket. Similar to FD_CLR

PARAMETERS

selector - Selector

selector_kind - Kind to clear

socket - Socket to clear

RETURN

-


SelectorSet(selector, selector_kind, socket)

Set selector for socket. Similar to FD_SET

Set selector for socket. Similar to FD_SET

PARAMETERS

selector - Selector

selector_kind - Kind to clear

socket - Socket to set

RETURN

-


SelectorIsSet(selector, selector_kind, socket)

Check if selector is set. Similar to FD_ISSET

Check if selector is set. Similar to FD_ISSET

PARAMETERS

selector - Selector

selector_kind - Selector kind

socket - Socket to check for

RETURN

- True if set.


SelectorZero(selector)

Clear selector (all kinds). Similar to FD_ZERO

Clear selector (all kinds). Similar to FD_ZERO

PARAMETERS

selector - Selector

RETURN

-


Select(selector, timeout)

Select for pending data

Select for pending data

PARAMETERS

selector - Selector

timeout - Timeout. For blocking pass -1. (microseconds)

RETURN

- RESULT_OK on success