Error Set ListenError [src]
Errors
Another socket is already listening on the same port. For Internet domain sockets, the socket referred to by sockfd had not previously been bound to an address and, upon attempting to bind it to an ephemeral port, it was determined that all port numbers in the ephemeral port range are currently in use. See the discussion of /proc/sys/net/ipv4/ip_local_port_range in ip(7).
Already connected
The file descriptor sockfd does not refer to a socket.
The network subsystem has failed.
The socket is not of a type that supports the listen() operation.
Socket has not been bound yet
Ran out of system resources On Windows it can either run out of socket descriptors or buffer space
The Operating System returned an undocumented error code.
This error is in theory not possible, but it would be better to handle this error than to invoke undefined behavior.
When this error code is observed, it usually means the Zig Standard Library needs a small patch to add the error code to the error set for the respective function.
Source
pub const ListenError = error{
/// Another socket is already listening on the same port.
/// For Internet domain sockets, the socket referred to by sockfd had not previously
/// been bound to an address and, upon attempting to bind it to an ephemeral port, it
/// was determined that all port numbers in the ephemeral port range are currently in
/// use. See the discussion of /proc/sys/net/ipv4/ip_local_port_range in ip(7).
AddressInUse,
/// The file descriptor sockfd does not refer to a socket.
FileDescriptorNotASocket,
/// The socket is not of a type that supports the listen() operation.
OperationNotSupported,
/// The network subsystem has failed.
NetworkSubsystemFailed,
/// Ran out of system resources
/// On Windows it can either run out of socket descriptors or buffer space
SystemResources,
/// Already connected
AlreadyConnected,
/// Socket has not been bound yet
SocketNotBound,
} || UnexpectedError