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 | .\" | |
3fa31615 | 5 | .\" @(#)listen.2 6.2 (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), | |
3fa31615 MK |
21 | a willingness to accept incoming connections and |
22 | a queue limit for incoming connections are specified with | |
23 | .IR listen (2), | |
cf65baf0 KM |
24 | and then the connections are |
25 | accepted with | |
26 | .IR accept (2). | |
27 | The | |
28 | .I listen | |
29 | call applies only to sockets of type | |
30 | SOCK_STREAM | |
31 | or | |
3fa31615 | 32 | SOCK_SEQPACKET. |
cf65baf0 KM |
33 | .PP |
34 | The | |
35 | .I backlog | |
36 | parameter defines the maximum length the queue of | |
37 | pending connections may grow to. | |
38 | If a connection | |
3fa31615 MK |
39 | request arrives with the queue full the client may |
40 | receive an error with an indication of ECONNREFUSED, | |
41 | or, if the underlying protocol supports retransmission, | |
42 | the request may be ignored so that retries may succeed. | |
cf65baf0 KM |
43 | .SH "RETURN VALUE |
44 | A 0 return value indicates success; \-1 indicates an error. | |
45 | .SH "ERRORS | |
46 | The call fails if: | |
47 | .TP 20 | |
48 | [EBADF] | |
49 | The argument \fIs\fP is not a valid descriptor. | |
50 | .TP 20 | |
51 | [ENOTSOCK] | |
52 | The argument \fIs\fP is not a socket. | |
53 | .TP 20 | |
54 | [EOPNOTSUPP] | |
55 | The socket is not of a type that supports the operation \fIlisten\fP. | |
56 | .SH "SEE ALSO" | |
57 | accept(2), connect(2), socket(2) | |
58 | .SH BUGS | |
59 | The | |
60 | .I backlog | |
61 | is currently limited (silently) to 5. |