Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (k - m) listen(2)
NAME
listen - Listens for socket connections and limits the backlog of incoming connections
LIBRARY
G-series native OSS processes: system library
H-series OSS processes: implicit libraries
SYNOPSIS
#define _XOPEN_SOURCE_EXTENDED 1
#include <sys/socket.h>
int listen(
int socket,
int backlog
);
PARAMETERS
socket Specifies the file descriptor for the socket.
backlog Specifies the maximum number of outstanding connections. The effect of this
parameter varies according to the connection type and the stack implementation
in use. Refer to the DESCRIPTION section of this reference page for more
information.
DESCRIPTION
The listen() function marks a connection-oriented socket as accepting connections, and limits
the number of outstanding connections in the socket’s queue to the value specified by the back-
log parameter.
For AF_INET sockets using conventional TCP/IP, a backlog parameter value of less than or
equal to 0 allows the socket to accept the number of connections configured for the TCP-
LISTEN-QUE-MIN parameter of the transport process. These values can allow up to 5 connec-
tions (the default value for TCP-LISTEN-QUE-MIN).
For AF_INET or AF_INET6 sockets using parallel library TCP/IP or TCP/IPv6, a backlog
parameter value of less than or equal to 0 is ignored. The maximum number of pending connec-
tions is always 5.
If the backlog parameter value is less than or equal to 0:
• For AF_UNIX Release 1 sockets or for AF_UNIX Release 2 sockets in compatibility
mode, subsequent calls to the connect() function that specify the path name to which the
listening socket is bound fail and errno is set to [ECONNREFUSED] unless there is a
pending accept() function call on the listening socket.
• For AF_UNIX Release 2 sockets in portability mode:
— Subsequent attempts to issue blocking calls to the connect() function that
specify the path name to which the listening socket is bound block the calling
process until there is a corresponding accept() call to the socket, at which time
the connect() function call succeeds. If there is no corresponding accept() call
within 2 minutes, the call to the connect() function fails and errno is set to
[ETIMEDOUT].
— Subsequent attempts to issue nonblocking calls to the connect() function that
specify the path name to which the listening socket is bound fail with errno set
to [EWOULDBLOCK], unless there is a pending accept() call to the socket, in
which case the connect() function call succeeds.
527186-023 Hewlett-Packard Company 4−19