Prepares a socket to accept a connection.
#include <sys/socket.h> int listen ( int s, int backlog);
(IN) Specifies the socket file handle that is to be prepared to accept a connection.
(IN) Specifies the maximum length for the queue of pending connections (the value of SOMAXCONN which is set to 5).
If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following:
The socket function creates a socket, the listen function prepares the socket to accept incoming connections and specifies a queue limit for incoming connections, and the accept function accepts the connection.
The listen function works for sockets only of type SOCK_STREAM and can be called to create a passive socket.
If a connect request arrives when the queue is full, the client receives an ECONNREFUSED error.