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