vibe.d beta banner
get vibe.d

Asynchronous I/O that doesn’t get in your way, written in D

Interface EventDriverSockets

Provides access to socket functionality.

interface EventDriverSockets ;

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


userData[set] TRetrieves a reference to a user-defined value associated with a descriptor.


addRef (descriptor) Increments the reference count of the given socket.
adoptDatagramSocket (socket) Adopts an existing datagram socket.
adoptStream (socket) Adopts an existing stream socket.
cancelConnectStream (sock) Aborts asynchronous connect by closing the socket.
cancelRead (socket) Cancels an ongoing read operation.
cancelReceive (socket) Cancels an ongoing wait for an incoming datagram.
cancelSend (socket) Cancels an ongoing wait for an outgoing datagram.
cancelWrite (socket) Cancels an ongoing write operation.
connectStream (peer_address, bind_address, on_connect) Connects to a stream listening socket.
createDatagramSocket (bind_address, target_address, options) Creates a connection-less datagram socket.
getConnectionState (sock) Determines the current connection state.
getLocalAddress (sock, dst) Retrieves the bind address of a socket.
getRemoteAddress (sock, dst) Retrieves the address of the connected peer.
isValid (handle) Determines whether the given socket handle is valid.
joinMulticastGroup (socket, multicast_address, interface_index) Joins the multicast group associated with the given IP address.
listenStream (bind_address, options, on_accept) Creates a socket listening for incoming stream connections.
listenStream (bind_address, on_accept)
read (socket, buffer, mode, on_read_finish) Reads data from a stream socket.
receive (socket, buffer, mode, on_receive_finish) Receives a single datagram.
releaseRef (descriptor) Decrements the reference count of the given socket.
send (socket, buffer, mode, target_address, on_send_finish) Sends a single datagram.
setBroadcast (socket, enable) Sets the SO_BROADCAST socket option.
setKeepAlive (socket, enable) Sets to SO_KEEPALIVE socket option on a socket.
setKeepAliveParams (socket, idle, interval, probeCount) Enables keepalive for the TCP socket and sets additional parameters. Silently ignores unsupported systems (anything but Windows and Linux).
setOption (socket, option, enable) Enables or disables a socket option.
setTargetAddress (socket, target_address) Sets an address to use as the default target address for sent datagrams.
setTCPNoDelay (socket, enable) Sets the TCP_NODELAY option on a socket
setUserTimeout (socket, timeout) Sets TCP_USER_TIMEOUT socket option (linux only).
shutdown (socket, shut_read, shut_write) Initiates a connection close.
waitForConnections (sock, on_accept) Starts to wait for incoming connections on a listening socket.
waitForData (socket, on_data_available) Waits for incoming data without actually reading it.
write (socket, buffer, mode, on_write_finish) Reads data from a stream socket.
rawUserData (descriptor, size, initialize, destroy) Low-level user data access. Use getUserData instead.