listen for connections on a socket
cc [options] file -lsocket -lnsl
int listen(int socket, int backlog);
To accept connections, a socket is first created with socket,
a backlog for incoming connections is specified with listen
and then the connections are accepted with accept.
The listen call applies only to sockets of type
SOCK_STREAM or SOCK_SEQPACKET.
parameter tcp_q0limit is set to 0, the backlog
parameter defines the maximum length to which the queues of
pending (3-way handshake incomplete) and established
(3-way handshake complete) connections may grow.
A connection request is silently dropped if it
arrives when the pending queue is full.
If the value of tcp_q0limit is greater than 0,
it determines the maximum length of the pending connection queue.
If a connection request arrives when the queue is full,
an existing pending connection is dropped at random
(RST is sent to the peer)
and the new request is placed on the queue.
In this case, the backlog parameter
defines only the maximum length to which the
established connection queue may grow.
If the value of backlog is less than 0,
the length of the socket's listen queue (or queues) is set to 0.
A value of 0 indicates success;
-1 indicates an error.
The call fails if:
is not a valid descriptor.
is not a socket.
The socket is not of a type that supports the operation listen.
The socket is already connected or has been shut down.
The socket is not bound to a local address, and the protocol does not
support listening on an unbound socket.
System resources are insufficient to complete the call.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004