eve.sys.windows.iocp

Supplemental Windows IOCP bindings not present in druntime.

Most IOCP and Winsock functionality is available via druntime's core.sys.windows.winbase and core.sys.windows.winsock2 modules. This module provides only the missing pieces needed by EVE's Layer 0.

Types 10

structWSABUF

Buffer descriptor for Winsock overlapped I/O.

Used with WSARecv, WSASend, and related functions to describe data buffers for scatter/gather I/O operations.

Fields
ULONG lenLength of the buffer in bytes.
ubyte * bufPointer to the buffer data.

Extended OVERLAPPED structure returned by GetQueuedCompletionStatusEx.

This structure is not present in druntime's winbase bindings.

Fields
ULONG_PTR lpCompletionKey
OVERLAPPED * lpOverlapped
ULONG_PTR Internal
DWORD dwNumberOfBytesTransferred
structGUID

GUID structure for Winsock extension function lookups.

Fields
uint Data1
ushort Data2
ushort Data3
ubyte[8] Data4
aliasAcceptExFunc = BOOL function( SOCKET sListenSocket, SOCKET sAcceptSocket, void * lpOutputBuffer, DWORD dwReceiveDataLength, DWORD dwLocalAddressLength, DWORD dwRemoteAddressLength, DWORD * lpdwBytesReceived, OVERLAPPED * lpOverlapped ) nothrow @nogc

Function pointer type for AcceptEx.

AcceptEx accepts a new connection, returns the local and remote addresses, and optionally receives the first block of data sent by the client.

aliasGetAcceptExSockaddrsFunc = void function( void * lpOutputBuffer, DWORD dwReceiveDataLength, DWORD dwLocalAddressLength, DWORD dwRemoteAddressLength, sockaddr * * LocalSockaddr, int * LocalSockaddrLength, sockaddr * * RemoteSockaddr, int * RemoteSockaddrLength ) nothrow @nogc

Function pointer type for GetAcceptExSockaddrs.

Parses the output buffer from AcceptEx to extract local and remote addresses.

aliasConnectExFunc = BOOL function( SOCKET s, const(sockaddr) * name, int namelen, void * lpSendBuffer, DWORD dwSendDataLength, DWORD * lpdwBytesSent, OVERLAPPED * lpOverlapped ) nothrow @nogc

Function pointer type for ConnectEx.

ConnectEx establishes a connection asynchronously.

aliasTransmitFileFunc = BOOL function( SOCKET hSocket, HANDLE hFile, DWORD nNumberOfBytesToWrite, DWORD nNumberOfBytesPerSend, OVERLAPPED * lpOverlapped, TRANSMIT_FILE_BUFFERS * lpTransmitBuffers, DWORD dwReserved ) nothrow @nogc

Function pointer type for TransmitFile.

TransmitFile transfers file data over a connected socket, optionally prepending and appending data buffers. Supports both synchronous and overlapped (IOCP) operation.

Buffers for TransmitFile head and tail data.

Allows sending header and trailer data alongside file content in a single TransmitFile call, avoiding extra send operations.

Fields
void * HeadPointer to data to send before the file.
DWORD HeadLengthLength of Head buffer in bytes.
void * TailPointer to data to send after the file.
DWORD TailLengthLength of Tail buffer in bytes.
structtcp_keepalive

TCP keepalive parameters structure for SIO_KEEPALIVE_VALS.

Used with WSAIoctl to configure keepalive behavior with finer granularity than the generic SO_KEEPALIVE socket option.

Fields
ULONG onoffEnable (1) or disable (0) keepalive probing.
ULONG keepalivetimeMilliseconds of idle time before the first keepalive probe.
ULONG keepaliveintervalMilliseconds between subsequent keepalive probes.
structWSADATA

Winsock startup data structure.

Fields
ushort wVersion
ushort wHighVersion
ushort iMaxSockets
ushort iMaxUdpDg
char * lpVendorInfo
char[257] szDescription
char[129] szSystemStatus

Functions 16

fnBOOL GetQueuedCompletionStatusEx( HANDLE CompletionPort, OVERLAPPED_ENTRY * lpCompletionPortEntries, ULONG ulCount, ULONG * ulNumEntriesRemoved, DWORD dwMilliseconds, BOOL fAlertable, ) extern(Windows) nothrow @nogcDequeue multiple completion packets from an I/O completion port.
fnBOOL CancelIoEx(HANDLE hFile, OVERLAPPED * lpOverlapped) extern(Windows) nothrow @nogcCancel pending I/O operations on a handle.
fnint WSARecv( SOCKET s, WSABUF * lpBuffers, DWORD dwBufferCount, DWORD * lpNumberOfBytesRecvd, DWORD * lpFlags, OVERLAPPED * lpOverlapped, void * lpCompletionRoutine ) extern(Windows) nothrow @nogcReceive data on a socket using overlapped I/O.
fnint WSASend( SOCKET s, WSABUF * lpBuffers, DWORD dwBufferCount, DWORD * lpNumberOfBytesSent, DWORD dwFlags, OVERLAPPED * lpOverlapped, void * lpCompletionRoutine ) extern(Windows) nothrow @nogcSend data on a socket using overlapped I/O.
fnint WSARecvFrom( SOCKET s, WSABUF * lpBuffers, DWORD dwBufferCount, DWORD * lpNumberOfBytesRecvd, DWORD * lpFlags, sockaddr * lpFrom, int * lpFromlen, OVERLAPPED * lpOverlapped, void * lpCompletionRoutine ) extern(Windows) nothrow @nogcReceive a datagram and store the source address using overlapped I/O.
fnint WSASendTo( SOCKET s, WSABUF * lpBuffers, DWORD dwBufferCount, DWORD * lpNumberOfBytesSent, DWORD dwFlags, const(sockaddr) * lpTo, int iTolen, OVERLAPPED * lpOverlapped, void * lpCompletionRoutine ) extern(Windows) nothrow @nogcSend a datagram to a specific destination using overlapped I/O.
fnSOCKET WSASocketW( int af, int type, int protocol, void * lpProtocolInfo, uint g, DWORD dwFlags ) extern(Windows) nothrow @nogcCreate a socket with extended options.
fnint WSAIoctl( SOCKET s, DWORD dwIoControlCode, void * lpvInBuffer, DWORD cbInBuffer, void * lpvOutBuffer, DWORD cbOutBuffer, DWORD * lpcbBytesReturned, OVERLAPPED * lpOverlapped, void * lpCompletionRoutine ) extern(Windows) nothrow @nogcRetrieve extension function pointer from Winsock.
fnAcceptExFunc loadAcceptEx(SOCKET s) @trusted nothrow @nogcLoad AcceptEx function pointer from a socket.
fnGetAcceptExSockaddrsFunc loadGetAcceptExSockaddrs(SOCKET s) @trusted nothrow @nogcLoad GetAcceptExSockaddrs function pointer from a socket.
fnConnectExFunc loadConnectEx(SOCKET s) @trusted nothrow @nogcLoad ConnectEx function pointer from a socket.
fnTransmitFileFunc loadTransmitFile(SOCKET s) @trusted nothrow @nogcLoad TransmitFile function pointer from a socket.
fnint WSAStartup(ushort wVersionRequested, WSADATA * lpWSAData) extern(Windows) nothrow @nogcInitialize Winsock.
fnint WSACleanup() extern(Windows) nothrow @nogcClean up Winsock.
fnushort MAKEWORD(ubyte major, ubyte minor) pure @safe nothrow @nogcCreate a Winsock version request value.
fnbool ensureWinsockInitialized() @trusted nothrow @nogcInitialize Winsock if not already initialized.

Variables 30

enumvarINVALID_SOCKET = cast(SOCKET) ~ cast(size_t) 0

Invalid socket sentinel value.

enumvarINFINITE = 0xFFFFFFFF

Infinite timeout value.

enumvarERROR_SUCCESS = 0

Common error codes.

enumvarERROR_IO_PENDING = 997
enumvarERROR_INVALID_HANDLE = 6
enumvarERROR_INVALID_PARAMETER = 87
enumvarERROR_NOT_FOUND = 1168
enumvarERROR_ALREADY_EXISTS = 183
enumvarERROR_IO_INCOMPLETE = 996
enumvarWSA_IO_PENDING = 997

Winsock error codes.

enumvarWSAECONNRESET = 10054
enumvarWSAEDISCON = 10101
enumvarWSA_FLAG_OVERLAPPED = 0x01

Winsock socket creation flags.

enumvarSIO_GET_EXTENSION_FUNCTION_POINTER = 0xC8000006

IOCTL code to retrieve extension function pointers.

varGUID WSAID_ACCEPTEX = GUID( 0xb5367df1, 0xcbac, 0x11cf, [0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92] )

GUID for AcceptEx function.

varGUID WSAID_CONNECTEX = GUID( 0x25a207b9, 0xddf3, 0x4660, [0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e] )

GUID for ConnectEx function.

varGUID WSAID_GETACCEPTEXSOCKADDRS = GUID( 0xb5367df2, 0xcbac, 0x11cf, [0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92] )

GUID for GetAcceptExSockaddrs function.

varGUID WSAID_TRANSMITFILE = GUID( 0xb5367df0, 0xcbac, 0x11cf, [0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92] )

GUID for TransmitFile function.

enumvarTF_DISCONNECT = 0x01

TransmitFile flags.

enumvarTF_REUSE_SOCKET = 0x02
enumvarTF_WRITE_BEHIND = 0x04
enumvarTF_USE_DEFAULT_WORKER = 0x00
enumvarTF_USE_SYSTEM_THREAD = 0x10
enumvarTF_USE_KERNEL_APC = 0x20
enumvarSO_UPDATE_ACCEPT_CONTEXT = 0x700B

Socket option to update accept context after AcceptEx.

enumvarSO_UPDATE_CONNECT_CONTEXT = 0x7010

Socket option to update connect context after ConnectEx.

enumvarSO_RCVBUF = 0x1002

Socket option for receive buffer size.

enumvarSO_SNDBUF = 0x1001

Socket option for send buffer size.

enumvarSIO_KEEPALIVE_VALS = 0x98000004

IOCTL code for setting TCP keepalive parameters.

enumvarWINSOCK_VERSION_2_2 = 0x0202

Winsock version 2.2 encoded.