listen(2)listen(2)NAMElisten - listen for connections on a socket
To accept connections, a socket is first created using a queue for
incoming connections is activated using and then connections are
accepted using applies only to unconnected sockets of type SOCK_STREAM.
Except for AF_VME_LINK, if the socket has not been bound to a local
port before is invoked, the system automatically binds a local port for
the socket to listen on (see inet(7F)). For sockets in the address
family AF_CCITT and AF_VME_LINK, the socket be bound to an address by
using before connection establishment can continue, otherwise an error
A listen queue is established for the socket specified by the s parame‐
ter, which is a socket descriptor.
backlog defines the desirable queue length for pending connections.
The actual queue length may be greater than the specified backlog. If
a connection request arrives when the queue is full, the client will
receive an error.
backlog is limited to the range of 0 to which is defined in is cur‐
rently set to 4096. If any other value is specified, the system auto‐
matically assigns the closest value within the range. Note that for a
backlog of 0 specifies only 1 pending connection is allowed at any
given time. For a backlog of 0 specifies no further connection is
X/Open Sockets Compilation Environment
Call-acceptance can be controlled by the call described in Upon suc‐
cessful completion, returns 0; otherwise, it returns −1 and sets to
indicate the error.
fails if any of the following conditions are encountered:
s is not a valid file descriptor.
The socket s has not been bound to an address by using
s is a valid file descriptor but it is not a
The socket referenced by
s does not support
The socket has been shut down or is already connected.
Linking binary objects compiled to specification and binary objects
compiled to specification to the same executable may result in unex‐
pected behavior, including application abnormal termination and unex‐
pected socket errors. See xopen_networking(7) for details and remedy.
Currently, the default behavior is the however, it might be changed to
in a future release. At that time, any behavior that is incompatible
with might be obsoleted. Applications that conform to the X/Open spec‐
ification now will avoid migration problems (see xopen_networking(7)).
was developed by HP and the University of California, Berkeley.
SEE ALSOaccept(2), connect(2), socket(2), thread_safety(5), xopen_network‐