listen(3XN)
NAME
listen − listen for socket connections and limit the queue of incoming connections
SYNOPSIS
cc [ flag ... ] file ... −lxnet [ library ... ]
#include <sys/socket.h>
int listen(int socket, int backlog);
DESCRIPTION
The listen() function marks a connection-mode socket, specified by the socket argument, as accepting connections, and limits the number of outstanding connections in the socket’s listen queue to the value specified by the backlog argument.
If listen() is called with a backlog argument value that is less than 0, the function sets the length of the socket’s listen queue to 0.
If backlog exceeds the maximum queue length, the length of the socket’s listen queue will be set to the maximum supported value.
RETURN VALUES
Upon successful completions, listen() returns 0. Otherwise, −1 is returned and errno is set to indicate the error.
ERRORS
The listen() function will fail if:
EBADF The socket argument is not a valid file descriptor.
ENOTSOCK The socket argument does not refer to a socket.
EOPNOTSUPP
The socket protocol does not support listen().
EINVAL The socket is already connected.
EDESTADDRREQ
The socket is not bound to a local address, and the protocol does not support listening on an unbound socket.
The listen() function may fail if:
EINVAL The socket has been shut down.
ENOBUFS Insufficient resources are available in the system to complete the call.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
| MT-Level | MT-Safe |
SEE ALSO
accept(3XN), connect(3XN), socket(3XN), attributes(5), socket(5)
SunOS 5.6 — Last change: 16 May 1997