The SockListen() call completes the binding necessary for a socket to accept connections and creates a connection request queue for incoming requests.
is the socket descriptor.
controls the maximum queue length for pending connections.
SockListen() performs the following tasks:
1. It completes the binding necessary for socket, if SockBind() has not been called for the socket.
It creates a connection request queue with a length of backlog to queue incoming connection requests.
When the queue is full, additional connection requests are ignored.
SockListen() can only be called for connection-oriented sockets.
SockListen() is called after allocating a socket with SockSocket() and after binding a name to socket with SockBind(). It must be called before SockAccept().
SockListen() indicates when it is ready to accept client connection requests. It transforms an active socket to a passive socket. After it is called, socket cannot be used as an active socket to initiate connection requests.
If backlog is smaller than 0, SockListen() interprets the backlog to be 0. If it is greater than the maximum value defined by the network system, SockListen() interprets the backlog to be this maximum value.
The value 0 indicates successful execution of the call. The value -1 indicates an error. You can get the specific error code SockSock_Errno() or SockPSock_Errno(). Possible values are:
socket is not a valid socket descriptor.
socket is not a socket descriptor that supports the SockListen() call.
Note: SockListen() interfaces with the C function listen().