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 with IOCP overlapped I/O support.
Backpressure is modelled via an all-or-nothing send policy: send() either accepts all bytes (OK) or rejects with PRESSURE. A per-connection send queue buffers data until the kernel can drain it. When the queue drains below the low water mark, onWritable fires.
Two I/O modes are available:
- WSAPoll mode (default) — synchronous non-blocking I/O with edge
notifications via the event loop poller.
- IOCP_OVERLAPPED mode — true asynchronous I/O using AcceptEx,
ConnectEx, WSARecv/WSASend with IOCP completion polling.
See Also
Types 4
Connection-side buffer configuration.
size_t highWaterMarkMaximum queued bytes before `send` starts reporting pressure.size_t lowWaterMarkQueue threshold below which `onWritable` may fire again.int recvBufferSizeSocket receive buffer size in bytes. 0 = use OS default.int sendBufferSizeSocket send buffer size in bytes. 0 = use OS default.bool keepAliveEnabledEnable TCP keepalive probes.uint keepAliveIdleTime in milliseconds before the first keepalive probe. Default: 60s.uint keepAliveIntervalTime in milliseconds between keepalive probes. Default: 10s.Listener-side socket configuration.
int backlogPending accept backlog passed to `listen`.int concurrentAcceptsNumber of concurrent `AcceptEx` operations to keep pending.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.
TcpConnection create(TcpConnectionConfig config = TcpConnectionConfig.init) static @trusted nothrowCreate a detached connection wrapper.void onConnect(ConnectCallback callback) @property @trusted Set the connect callback. Fires once when the TLS/TCP handshake completes successfully. Thread affinity: event loop thread only. Non-reentrant. Does not fire after `dispose()`. Params: ...void onData(DataCallback callback) @property @trusted Set the inbound data callback. Fires when data arrives. The `data` parameter is borrowed — valid only for the duration of the callback. Copy it if needed beyond. Thread affinity: event loop ...void onWritable(WritableCallback callback) @property @trusted Set the writable callback. Fires when the send queue drains below the low water mark after backpressure. Not called on initial connect. Thread affinity: event loop thread only. Non-reentrant. ...void onClose(CloseCallback callback) @property @trusted Set the close callback. Fires when the remote end closes the connection or a fatal error occurs. May fire after `close()` if data was still pending. Does not fire after `dispose()`. Thread af...void onError(ErrorCallback callback) @property @trusted Set the error callback. Fires on connection errors. After this callback, the connection enters an error state; `onClose` may or may not follow. Thread affinity: event loop thread only. Non-ree...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.AdoptStatus adopt(ref EventLoop loop, Handle clientHandle) @trusted nothrowAdopt an already-accepted client socket.ConnectStatus connect(ref EventLoop loop, scope const(char)[] host, ushort port, CancelToken cancel = CancelToken
.invalid) @trusted nothrowStart a non-blocking connection attempt.SendStatus sendFile(HANDLE fileHandle, ulong offset, size_t count) @trusted nothrowSend a file over the connection using zero-copy TransmitFile.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.
TcpListener create(TcpListenerConfig config = TcpListenerConfig.init) static @trustedCreate a detached listener wrapper.void onAccept(AcceptCallback callback) @property @trusted Set the accept callback. Fires when a new client connection is accepted. The `clientHandle` is *caller-owned — you must call `TcpConnection.adopt()` to take ownership, or close it via `close...void onConnection(ConnectionCallback callback) @property @trustedSet the high-level connection callback.void onError(ListenerErrorCallback callback) @property @trustedSet the error callback for accept failures.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.ListenStatus listen(ref EventLoop loop, scope const(char)[] host, ushort port) @trustedStart listening on the requested endpoint.