EventDriverSockets

Provides access to socket functionality.

The interface supports two classes of sockets - stream sockets and datagram sockets.

interface EventDriverSockets {}

Members

Functions

addRef
void addRef(SocketFD descriptor)

Increments the reference count of the given socket.

adoptDatagramSocket
DatagramSocketFD adoptDatagramSocket(int socket)

Adopts an existing datagram socket.

adoptStream
StreamSocketFD adoptStream(int socket)

Adopts an existing stream socket.

cancelConnectStream
void cancelConnectStream(StreamSocketFD sock)

Aborts asynchronous connect by closing the socket.

cancelRead
void cancelRead(StreamSocketFD socket)

Cancels an ongoing read operation.

cancelReceive
void cancelReceive(DatagramSocketFD socket)

Cancels an ongoing wait for an incoming datagram.

cancelSend
void cancelSend(DatagramSocketFD socket)

Cancels an ongoing wait for an outgoing datagram.

cancelWrite
void cancelWrite(StreamSocketFD socket)

Cancels an ongoing write operation.

connectStream
StreamSocketFD connectStream(Address peer_address, Address bind_address, ConnectCallback on_connect)

Connects to a stream listening socket.

createDatagramSocket
DatagramSocketFD createDatagramSocket(Address bind_address, Address target_address, DatagramCreateOptions options)

Creates a connection-less datagram socket.

getConnectionState
ConnectionState getConnectionState(StreamSocketFD sock)

Determines the current connection state.

getLocalAddress
bool getLocalAddress(SocketFD sock, RefAddress dst)

Retrieves the bind address of a socket.

getRemoteAddress
bool getRemoteAddress(SocketFD sock, RefAddress dst)

Retrieves the address of the connected peer.

isValid
bool isValid(SocketFD handle)

Determines whether the given socket handle is valid.

joinMulticastGroup
bool joinMulticastGroup(DatagramSocketFD socket, Address multicast_address, uint interface_index)

Joins the multicast group associated with the given IP address.

listenStream
StreamListenSocketFD listenStream(Address bind_address, StreamListenOptions options, AcceptCallback on_accept)

Creates a socket listening for incoming stream connections.

listenStream
StreamListenSocketFD listenStream(Address bind_address, AcceptCallback on_accept)
Undocumented in source. Be warned that the author may not have intended to support it.
rawUserData
void* rawUserData(StreamSocketFD descriptor, size_t size, DataInitializer initialize, DataInitializer destroy)
void* rawUserData(StreamListenSocketFD descriptor, size_t size, DataInitializer initialize, DataInitializer destroy)
void* rawUserData(DatagramSocketFD descriptor, size_t size, DataInitializer initialize, DataInitializer destroy)

Low-level user data access. Use getUserData instead.

read
void read(StreamSocketFD socket, ubyte[] buffer, IOMode mode, IOCallback on_read_finish)

Reads data from a stream socket.

receive
void receive(DatagramSocketFD socket, ubyte[] buffer, IOMode mode, DatagramIOCallback on_receive_finish)

Receives a single datagram.

releaseRef
bool releaseRef(SocketFD descriptor)

Decrements the reference count of the given socket.

send
void send(DatagramSocketFD socket, const(ubyte)[] buffer, IOMode mode, Address target_address, DatagramIOCallback on_send_finish)

Sends a single datagram.

setBroadcast
bool setBroadcast(DatagramSocketFD socket, bool enable)

Sets the SO_BROADCAST socket option.

setKeepAlive
void setKeepAlive(StreamSocketFD socket, bool enable)

Sets to SO_KEEPALIVE socket option on a socket.

setKeepAliveParams
void setKeepAliveParams(StreamSocketFD socket, Duration idle, Duration interval, int probeCount)

Enables keepalive for the TCP socket and sets additional parameters. Silently ignores unsupported systems (anything but Windows and Linux).

setOption
bool setOption(DatagramSocketFD socket, DatagramSocketOption option, bool enable)
bool setOption(StreamSocketFD socket, StreamSocketOption option, bool enable)

Enables or disables a socket option.

setTCPNoDelay
void setTCPNoDelay(StreamSocketFD socket, bool enable)

Sets the TCP_NODELAY option on a socket

setTargetAddress
void setTargetAddress(DatagramSocketFD socket, Address target_address)

Sets an address to use as the default target address for sent datagrams.

setUserTimeout
void setUserTimeout(StreamSocketFD socket, Duration timeout)

Sets TCP_USER_TIMEOUT socket option (linux only). https://tools.ietf.org/html/rfc5482

shutdown
void shutdown(StreamSocketFD socket, bool shut_read, bool shut_write)

Initiates a connection close.

waitForConnections
void waitForConnections(StreamListenSocketFD sock, AcceptCallback on_accept)

Starts to wait for incoming connections on a listening socket.

waitForData
void waitForData(StreamSocketFD socket, IOCallback on_data_available)

Waits for incoming data without actually reading it.

write
void write(StreamSocketFD socket, const(ubyte)[] buffer, IOMode mode, IOCallback on_write_finish)

Reads data from a stream socket.

Properties

userData
FD userData [@property setter]
deprecated FD userData [@property setter]

Retrieves a reference to a user-defined value associated with a descriptor.

Meta