LISTEN(2) — Series 300 and 800 Only
NAME
listen − listen for connections on a socket
SYNOPSIS
listen(s, backlog)
int s, backlog;
DESCRIPTION
To accept connections, a socket is first created with socket(2), a queue for incoming connections is specified with listen(2) and then connections are accepted with accept(2). The listen call applies only to unconnected sockets of type SOCK_STREAM. If the socket has not been bound to a local port before the listen is invoked, the system automatically binds a local port for the socket to listen on (see inet(7F)).
The listen queue is established for the socket specified by the s parameter, which is a socket descriptor.
The backlog parameter defines the maximum allowable length of the queue for pending connections. If a connection request arrives when the queue is full, the client receives an ETIMEDOUT error.
Backlog is currently limited (silently) to be in the range of 1 to 20. If you specify any other value, the system automatically assigns the closest value within range.
RETURN VALUE
If the call is successful, 0 is returned. If the call fails, −1 is returned and an error code is stored in errno.
DIAGNOSTICS
The listen call fails if:
[EBADF] The argument s is not a valid descriptor.
[ENOTSOCK] The argument s is not a socket.
[EOPNOTSUPP] The socket is not of a type that supports the listen operation.
[ENOBUFS] Series 300 Only: No buffer space is available. Listen can not be started at this time.
[EINVAL] The socket has been shut down or is already connected.
DEPENDENCIES
Implemented on the Series 300 and 800 only.
AUTHOR
UCB (University of California at Berkeley)
SEE ALSO
accept(2), connect(2), socket(2), inet(7F).
Hewlett-Packard Company — May 11, 2021