class AsyncSocket

Proactor-model inspired asynchronous socket implementation. In contrast to POSIX.1-2013 readiness I/O - which essentially describes synchronous socket I/O operations with asynchronous notification of future blocking behaviour for said operations - this provides an API for asynchronous socket I/O operations: The three major socket operations accept, receive, and send modeled by this API will submit a request for asynchronous completion; towards that end, each call to these must be provided with a callback that will be called to notify you of said competion. It is therefore not recommended to keep calling any of these three methods in rapid succession, as they will normally not fail (bugs, memory exhaustion, or the operating system not supporting further pending requests excluded) to notify you that you should try again later. They will, however, notify you via the callbacks you provide once a request has been completed, or once there has been a socket error (refer to OnError). It follows that you should usually have only a small number of requests pending on a socket at the same time (preferably at most only a single receive and a single send - respectively a single accept) and submit the next request only once the previous one (of the same type) notifies you of its completion. For connection-oriented, active sockets, connection completion and disconnect (by the remote peer) are handled by OnConnect and OnClose respectively; disconnecting from the remote peer can be initiated with kill and will not trigger OnClose.


bool isConnectionOriented(SocketType type)

Returns true if the given type of socket is connection-oriented.

bool isDatagramOriented(SocketType type)

Returns true if the given type of socket is datagram-oriented.

bool isSocket(fd_t fd)

Checks whether the given file descriptor refers to a valid socket.


struct AsyncAcceptRequest

Represents a single request to asynchronously accept an incoming connection.

struct AsyncReceiveRequest

Represents a single request to asynchronously receive data.

struct AsyncSendRequest

Represents a single request to asynchronously send data.

struct NetworkAddress

Represents a network/socket address. (adapted from

struct NetworkMessage

Represents a single message to be transferred over the network by AsyncSocket.

struct SocketInfo

Holds additional information about a socket.