listen
Purpose
Listens for connections on a socket.
Library
Sockets Library (libsock.a)
Syntax
int listen (s, backlog)
int s, backlog;
Description
To accept connections, create a socket with socket,
specify a backlog for incoming connections with listen,
and accept the connections with accept. The listen sub-
routine applies only to sockets of type SOCK_STREAM.
The backlog parameter defines the maximum length for the
queue of pending connections. If a connection request
arrives with the queue full, the client receives an error
with an indication of ECONNREFUSED.
Return Value
Upon successful completion, a value of 0 is returned. If
the listen routine fails, a value of -1 is returned, and
errno is set to indicate the error.
Diagnostics
The subroutine fails if one or more of the following are
true:
EBADF The s parameter is not valid.
ENOTSOCK The s parameter refers to a file, not a
socket.
EOPNOTSUPP The referenced socket is not of type
that supports listen.
Related Information
In this book: "accept," "connect," and "socket."