eve.aio.posix.udp
Async UDP datagram socket primitives for POSIX platforms.
This module provides the POSIX implementation of UDP networking primitives using standard BSD sockets API. It works on Linux, BSD, and macOS.
UDP is message-oriented: each send/receive operates on complete datagrams. Unlike TCP, there is no connection state or backpressure mechanism.
class UdpSocketState
Types 7
structUdpSocketConfig
UDP socket configuration.
Fields
size_t maxDatagramSizeMaximum datagram size for receive buffer.bool reuseAddrEnable SO_REUSEADDR on bind.bool broadcastEnable SO_BROADCAST for sending broadcast messages.Methods
structSocketAddress
Represents a remote endpoint address.
Fields
ushort familyAddress family (AFINET or AFINET6).ushort portPort number in host byte order.ubyte[4] ipv4IPv4 address bytes (only valid if family == AF_INET).ubyte[16] ipv6IPv6 address bytes (only valid if family == AF_INET6).private aliasDataCallback = void delegate(
ref UdpSocket socket, scope const(ubyte)[] data, SocketAddress sender) @safe
structUdpSocket
Async UDP socket wrapper.
Wraps a non-blocking UDP socket and integrates with the Layer 1 event loop for async send/receive operations.
Fields
UdpSocketState _stateMethods
UdpSocket create(UdpSocketConfig config = UdpSocketConfig.init) @trustedCreate a detached UDP socket wrapper.int bind(ref EventLoop loop, scope const(char)[] host, ushort port) @trustedBind the socket to a local endpoint.DatagramResult sendTo(scope const(ubyte)[] data, scope const(char)[] host, ushort port) @trustedSend a datagram to a specific destination.DatagramResult sendToAddress(scope const(ubyte)[] data, SocketAddress dest) @trustedSend a datagram to a specific destination address.UdpSocketState mutableState() @trustedFields
DataCallback onDataErrorCallback onErrorEventLoop * _loopHandle _handleToken _tokenUdpSocketConfig _configushort _localPortbool _receivingPausedubyte[] _recvBufferMethods
DatagramResult sendTo(scope const(ubyte)[] data, scope const(char)[] host, ushort port) @trusted nothrowConstructors
this(UdpSocketConfig config)Range adapter for iterating over addrinfo linked list.
Fields
addrinfo * currentFunctions 8
private fn
UdpSocketConfig validated(UdpSocketConfig config) pure @safe nothrow @nogcValidate a socket 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
SocketAddress parseSocketAddress(ref const sockaddr_storage storage) @trusted nothrow @nogcParse a sockaddr_storage into a SocketAddress.private fn
AddrinfoRange addrinfoRange(addrinfo * first) pure @safe nothrow @nogcCreate a range over an addrinfo linked list.