BSD 4_2 development
[unix-history] / usr / man / man2 / listen.2
CommitLineData
bd121f65
C
1.TH LISTEN 2 "12 February 1983"
2.UC 4
3.SH NAME
4listen \- listen for connections on a socket
5.SH SYNOPSIS
6.nf
7.ft B
8listen(s, backlog)
9int s, backlog;
10.fi
11.SH DESCRIPTION
12To accept connections, a socket
13is first created with
14.IR socket (2),
15a backlog for incoming connections is specified with
16.IR listen (2)
17and then the connections are
18accepted with
19.IR accept (2).
20The
21.I listen
22call applies only to sockets of type
23SOCK_STREAM
24or
25SOCK_PKTSTREAM.
26.PP
27The
28.I backlog
29parameter defines the maximum length the queue of
30pending connections may grow to.
31If a connection
32request arrives with the queue full the client will
33receive an error with an indication of ECONNREFUSED.
34.SH "RETURN VALUE
35A 0 return value indicates success; \-1 indicates an error.
36.SH "ERRORS
37The call fails if:
38.TP 20
39[EBADF]
40The argument \fIs\fP is not a valid descriptor.
41.TP 20
42[ENOTSOCK]
43The argument \fIs\fP is not a socket.
44.TP 20
45[EOPNOTSUPP]
46The socket is not of a type that supports the operation \fIlisten\fP.
47.SH "SEE ALSO"
48accept(2), connect(2), socket(2)
49.SH BUGS
50The
51.I backlog
52is currently limited (silently) to 5.