LISTEN(2)
NAME
listen − listen for connections on a socket
USAGE
listen(s, backlog) int s, backlog;
DESCRIPTION
To accept connections, a socket is created with socket(2), a backlog for incoming connections is specified with listen(2), and the connections are accepted with accept(2).
The backlog parameter defines the maximum length of the queue of pending connections. If a connection request arrives and the queue is full, the client will receive the error ECONNREFUSED.
NOTES
The maximum value for backlog is five.
The listen call applies only to sockets of the type SOCK_STREAM or SOCK_PKTSTREAM.
RETURN VALUE
A successful call returns zero. A failed call returns -1 and sets errno as indicated below.
ERRORS
The call fails if:
[EBADF] The argument s is not a valid descriptor.
[ENOTSOCK] The argument s is not a socket.
[EOPNOTSUPP] The socket type is unsupported by listen (it is not one of type SOCK_STREAM or SOCK_PKTSTREAM).