spelling
[unix-history] / usr / src / lib / libc / sys / listen.2
CommitLineData
cf65baf0
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
3fa31615 5.\" @(#)listen.2 6.2 (Berkeley) %G%
cf65baf0 6.\"
ca13daa8 7.TH LISTEN 2 ""
cf65baf0
KM
8.UC 5
9.SH NAME
10listen \- listen for connections on a socket
11.SH SYNOPSIS
12.nf
13.ft B
14listen(s, backlog)
15int s, backlog;
16.fi
17.SH DESCRIPTION
18To accept connections, a socket
19is first created with
20.IR socket (2),
3fa31615
MK
21a willingness to accept incoming connections and
22a queue limit for incoming connections are specified with
23.IR listen (2),
cf65baf0
KM
24and then the connections are
25accepted with
26.IR accept (2).
27The
28.I listen
29call applies only to sockets of type
30SOCK_STREAM
31or
3fa31615 32SOCK_SEQPACKET.
cf65baf0
KM
33.PP
34The
35.I backlog
36parameter defines the maximum length the queue of
37pending connections may grow to.
38If a connection
3fa31615
MK
39request arrives with the queue full the client may
40receive an error with an indication of ECONNREFUSED,
41or, if the underlying protocol supports retransmission,
42the request may be ignored so that retries may succeed.
cf65baf0
KM
43.SH "RETURN VALUE
44A 0 return value indicates success; \-1 indicates an error.
45.SH "ERRORS
46The call fails if:
47.TP 20
48[EBADF]
49The argument \fIs\fP is not a valid descriptor.
50.TP 20
51[ENOTSOCK]
52The argument \fIs\fP is not a socket.
53.TP 20
54[EOPNOTSUPP]
55The socket is not of a type that supports the operation \fIlisten\fP.
56.SH "SEE ALSO"
57accept(2), connect(2), socket(2)
58.SH BUGS
59The
60.I backlog
61is currently limited (silently) to 5.