eve.aio.posix.tcp
Async TCP listener and connection primitives for POSIX platforms.
This module provides the POSIX implementation of TCP networking primitives using standard BSD sockets API. It works on Linux, BSD, and macOS.
Types 14
structTcpConnectionConfig
Connection-side buffer configuration.
Fields
size_t highWaterMarkMaximum queued bytes before `send` starts reporting pressure.size_t lowWaterMarkQueue threshold below which `onWritable` may fire again.Methods
structTcpListenerConfig
Listener-side socket configuration.
Fields
int backlogPending accept backlog passed to `listen(2)`.Methods
private aliasDataCallback = void delegate(ref TcpConnection connection, scope const(ubyte)[] data) @safe
private aliasCloseCallback = void delegate(ref TcpConnection connection, SocketCloseReason reason) @safe
private aliasConnectionCallback = void delegate(ref TcpListener listener, ref TcpConnection connection) @safe
structTcpConnection
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.
Fields
TcpConnectionState _stateMethods
TcpConnection 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.structTcpListener
Async TCP listener wrapper.
Wraps a non-blocking TCP listening socket and integrates with the Layer 1 event loop for async accept operations.
Fields
TcpListenerState _stateMethods
TcpListener 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.Fields
ConnectCallback onConnectDataCallback onDataWritableCallback onWritableCloseCallback onCloseErrorCallback onErrorEventLoop * _loopHandle _handleToken _tokenTcpConnectionConfig _configbool _readingPausedbool _watchingWritebool _awaitingWritablebool _closeDeliveredubyte[] _sendQueueSocketState _stateIpAddress _remoteAddressIpAddress _localAddressCancelToken _cancelTokenCancelToken _shutdownTokenbool _drainingMethods
ConnectResult connect(ref EventLoop loop, scope const(char)[] host, ushort port, CancelToken cancel = CancelToken
.invalid) @trusted nothrowSendResult send(scope const(ubyte)[] data) @trustedConstructors
this(TcpConnectionConfig config)Fields
AcceptCallback onAcceptConnectionCallback onConnectionEventLoop * _loopHandle _handleToken _tokenTcpListenerConfig _configushort _localPortCancelToken _shutdownTokenbool _drainingMethods
Constructors
this(TcpListenerConfig config)Range adapter for iterating over addrinfo linked list.
Fields
addrinfo * currentFunctions 12
private fn
TcpConnectionConfig validated(TcpConnectionConfig config) pure @safe nothrow @nogcValidate a connection config, returning defaults if invalid.private fn
TcpListenerConfig validated(TcpListenerConfig config) pure @safe nothrow @nogcValidate a listener config, returning defaults if invalid.private fn
const(char) * copyStringz(scope const(char)[] source, scope char[] buffer) @trusted nothrowCopy a D string slice to a null-terminated C string buffer.private fn
bool wouldBlock(int value) pure @safe nothrow @nogcCheck if an errno value indicates the operation would block.private fn
int resolveErrno(int status) @trusted nothrowConvert getaddrinfo error to errno equivalent.private fn
ushort queryLocalPort(int fd) @trusted nothrowQuery the local port number for a bound socket.private fn
AddrinfoRange addrinfoRange(addrinfo * first) pure @safe nothrow @nogcCreate a range over an addrinfo linked list.