eve.aio.windows.tcp
Async TCP listener and connection primitives for Windows.
This module provides the Windows implementation of TCP networking primitives using Winsock2 API.
Types 14
Connection-side buffer configuration.
size_t highWaterMarkMaximum queued bytes before `send` starts reporting pressure.size_t lowWaterMarkQueue threshold below which `onWritable` may fire again.Listener-side socket configuration.
int backlogPending accept backlog passed to `listen`.Async TCP connection wrapper.
Wraps a non-blocking TCP socket and integrates with the Layer 1 event loop for async read/write operations with backpressure support.
TcpConnectionState _stateTcpConnection create(TcpConnectionConfig config = TcpConnectionConfig.init) @trusted nothrowCreate a detached connection wrapper.bool isOpen() @property const @safe nothrow @nogcReport whether the wrapper currently owns an open socket.bool isWritable() @property const @safe nothrow @nogcReport whether the connection is currently writable from the caller's perspective.IpAddress remoteAddress() @property const @safe nothrow @nogcReport the remote address of the connection.IpAddress localAddress() @property const @safe nothrow @nogcReport the local address of the connection.AdoptResult adopt(ref EventLoop loop, Handle clientHandle) @trusted nothrowAdopt an already-accepted client socket.ConnectResult connect(ref EventLoop loop, scope const(char)[] host, ushort port, CancelToken cancel = CancelToken
.invalid) @trusted nothrowStart a non-blocking connection attempt.bool track(Coord)(ref Coord coordinator) @trusted nothrowTrack this connection for graceful shutdown.Async TCP listener wrapper.
Wraps a non-blocking TCP listening socket and integrates with the Layer 1 event loop for async accept operations.
TcpListenerState _stateTcpListener create(TcpListenerConfig config = TcpListenerConfig.init) @trustedCreate a detached listener wrapper.void onConnection(ConnectionCallback callback) @property @trustedSet the high-level connection callback.bool isOpen() @property const @safe nothrow @nogcReport whether the listener currently owns an open socket.ushort localPort() @property const @safe nothrow @nogcReport the effective local port once listening.ListenResult listen(ref EventLoop loop, scope const(char)[] host, ushort port) @trustedStart listening on the requested endpoint.ConnectCallback onConnectDataCallback onDataWritableCallback onWritableCloseCallback onCloseErrorCallback onErrorEventLoop * _loopSOCKET _socketToken _tokenTcpConnectionConfig _configbool _readingPausedbool _watchingWritebool _awaitingWritablebool _closeDeliveredubyte[] _sendQueueSocketState _stateint _lastErrorIpAddress _remoteAddressIpAddress _localAddressCancelToken _cancelTokenCancelToken _shutdownTokenbool _drainingbool _useOverlappedIoWhether this connection uses overlapped I/O mode.Token _prepareTokenPrepare token for polling IOCP completion status.OVERLAPPED _readOverlappedOverlapped structure for pending read operations.OVERLAPPED _writeOverlappedOverlapped structure for pending write operations.ubyte[TCP_READ_BUFFER_SIZE] _readBufferRead buffer — must remain valid during overlapped read.ubyte[TCP_READ_BUFFER_SIZE] _writeBufferWrite buffer — must remain valid during overlapped write.bool _readInProgressWhether a read operation is currently in progress.bool _writeInProgressWhether a write operation is currently in progress.size_t _pendingWriteLenNumber of bytes in the current pending write.ConnectExFunc _connectExConnectEx function pointer (loaded on first use).OVERLAPPED _connectOverlappedOverlapped structure for pending connect operation.bool _connectInProgressWhether a connect operation is currently in progress.ubyte[] _pausedReceiveBufferBuffer for data received while reading is paused (IOCP mode only). When paused, incoming data is stored here instead of being delivered.ConnectResult connect(ref EventLoop loop, scope const(char)[] host, ushort port, CancelToken cancel = CancelToken
.invalid) @trusted nothrowint bindToAnyAddress(SOCKET sock, int family) @trusted nothrowBind socket to any available local address.int submitConnectEx(const(sockaddr) * addr, int addrlen) @trusted nothrowSubmit a ConnectEx operation.void handlePrepare(ref EventLoop loop, Token token) @trusted nothrowHandle prepare phase callback from the event loop.this(TcpConnectionConfig config)AcceptCallback onAcceptConnectionCallback onConnectionEventLoop * _loopSOCKET _socketToken _tokenTcpListenerConfig _configushort _localPortint _lastErrorCancelToken _shutdownTokenbool _drainingbool _useOverlappedIoWhether this listener uses overlapped I/O mode (AcceptEx).Token _prepareTokenPrepare token for polling IOCP completion status.AcceptExFunc _acceptExAcceptEx function pointer.GetAcceptExSockaddrsFunc _getAcceptExSockaddrsGetAcceptExSockaddrs function pointer.int _addressFamilyAddress family of the listen socket (AFINET or AFINET6).SOCKET _acceptSocketPre-created socket for the pending accept operation.OVERLAPPED _acceptOverlappedOverlapped structure for pending accept operation.ubyte[ACCEPT_BUFFER_SIZE] _acceptBufferBuffer for AcceptEx output (local + remote addresses).bool _acceptInProgressWhether an accept operation is currently in progress.void handlePrepare(ref EventLoop loop, Token token) @trusted nothrowHandle prepare phase callback from the event loop.this(TcpListenerConfig config)Range adapter for iterating over addrinfo linked list.
addrinfo * currentFunctions 13
ListenResult mapListenError(int err) pure @safe nothrow @nogcMap Winsock error code to ListenResult.ConnectResult mapConnectError(int err) pure @safe nothrow @nogcMap Winsock error code to ConnectResult.AdoptResult mapAdoptError(int err) pure @safe nothrow @nogcMap Winsock error code to AdoptResult.TcpConnectionConfig validated(TcpConnectionConfig config) pure @safe nothrow @nogcValidate a connection config, returning defaults if invalid.TcpListenerConfig validated(TcpListenerConfig config) pure @safe nothrow @nogcValidate a listener config, returning defaults if invalid.const(char) * copyStringz(scope const(char)[] source, scope char[] buffer) @trusted nothrowCopy a D string slice to a null-terminated C string buffer.const(char) * portToString(ushort port, scope char[] buffer) @trusted nothrowConvert a port number to a null-terminated string.bool wouldBlock() @trusted nothrowCheck if the last Winsock error indicates the operation would block.int mapWsaError(int wsaError) pure @safe nothrow @nogcMap Winsock error code to POSIX-style errno.ushort queryLocalPort(SOCKET sock) @trusted nothrowQuery the local port number for a bound socket.AddrinfoRange addrinfoRange(addrinfo * first) pure @safe nothrow @nogcCreate a range over an addrinfo linked list.Variables 4
SOMAXCONN = 0x7fffffffMaximum listen backlog (not in druntime's winsock2).
TCP_READ_BUFFER_SIZE = 8192Size of the internal read/write buffer for overlapped I/O.
ACCEPT_ADDR_LEN = SOCKADDR_STORAGE.sizeof + 16Size of address buffer for AcceptEx (sockaddr_storage + 16 bytes padding).
ACCEPT_BUFFER_SIZE = ACCEPT_ADDR_LEN * 2Total buffer size for AcceptEx (local + remote addresses).