'\"macro stdmacro
.if n .pH g3n.listen @(#)listen	40.7 of 1/29/90
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} listen 3N "" "\&"
.if \nX=1 .ds x} listen 3N ""
.if \nX=2 .ds x} listen 3N "" "\&"
.if \nX=3 .ds x} listen "" "" "\&"
.TH \*(x}
.SH NAME
\f4listen\fP \- listen for connections on a socket
.SH SYNOPSIS
.nf
.ft CW
listen(s, backlog)
int s, backlog;
.ft P
.fi
.SH DESCRIPTION
.LP
To accept connections, a socket is first created with \f4socket\f1(2),
a backlog for incoming connections is specified with \f4listen(\|)\f1
and then the connections are accepted with \f4accept\f1(2).
The \f4listen(\|)\f1 call applies only to sockets of type
\f4SOCK_STREAM\fP or \f4SOCK_SEQPACKET\fP.
.LP
The
.I backlog
parameter defines the maximum length the queue of
pending connections may grow to.
If a connection
request arrives with the queue full, the client will
receive an error with an indication of \f4ECONNREFUSED\f1.
.SH "RETURN VALUE
.LP
A \f40\fP return value indicates success;
\f4-1\fP indicates an error.
.SH ERRORS
.LP
The call fails if:
.TP 20
\f4EBADF\f1
The argument
.I s
is not a valid descriptor.
.TP
\f4ENOTSOCK\f1
The argument
.I s
is not a socket.
.TP
\f4EOPNOTSUPP\f1
The socket is not of a type that supports the operation \f4listen\f1.
.\".SH "SEE ALSO"
.\".BR accept (2),
.\".BR connect (2),
.\".BR socket (2)
.SH NOTES
.LP
There is currently no
.I backlog
limit.
