Skip to main content

Module net

Module net 

Source
Expand description

Non-blocking TCP and UDP sockets on raw file descriptors (Unix) and SOCKETs (Windows).

Socket owns the descriptor and closes it on drop (through std’s OwnedFd / OwnedSocket). Every socket this module creates is non-blocking and close-on-exec (not inheritable on Windows), and on Windows it is created overlapped so IOCP can drive it. Operations that would block return an error of kind io::ErrorKind::WouldBlock.

Structs§

ListenOptions
Options for Socket::tcp_listen.
Socket
An owned, non-blocking socket. Closed on drop.
UdpOptions
Options for Socket::udp_bind.

Functions§

default_backlog
The default listen backlog: the system’s maximum accept queue. On Linux that is /proc/sys/net/core/somaxconn (read once), capped at 65535, or 4096 if it can’t be read; on Windows SOMAXCONN (the provider’s maximum); elsewhere 65535, which the kernel clamps to its own somaxconn.
descriptor_limit
The process’s soft limit on open file descriptors (RLIMIT_NOFILE on Linux); None where there is no such limit to watch (Windows) or it can’t be read.
reserve_descriptors
The unspecified address of the same family as addr (port 0). Grows the process’s file descriptor table to hold at least n descriptors (capped at the soft RLIMIT_NOFILE), by duplicating a descriptor to slot n - 1 and closing it again.
unspecified_like

Type Aliases§

RawSock
The raw OS handle of a socket: a file descriptor on Unix, a SOCKET on Windows.