The backlog argument defines the maximum length to which the queue of pending connections for sockfd may grow. If a connec‐ tion request arrives when the queue is full, the client may receive an error with an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may be ignored so that a later reattempt at connection succeeds.
0 on success or -1 on failure. On failure errno is set appropriately.
Errors: EADDRINUSE Another socket is already listening on the same port.
EBADF The argument sockfd is not a valid descriptor.
ENOTSOCK The argument sockfd is not a socket.
EOPNOTSUPP The socket is not of a type that supports the listen() operation.
listen() marks this socket as a passive socket, that is, as a socket that will be used to accept incoming connection requests using accept().