Commit | Line | Data |
---|---|---|
da268306 KB |
1 | .\" Copyright (c) 1983 The Regents of the University of California. |
2 | .\" All rights reserved. | |
cf65baf0 | 3 | .\" |
da268306 KB |
4 | .\" Redistribution and use in source and binary forms are permitted |
5 | .\" provided that the above copyright notice and this paragraph are | |
6 | .\" duplicated in all such forms and that any documentation, | |
7 | .\" advertising materials, and other materials related to such | |
8 | .\" distribution and use acknowledge that the software was developed | |
9 | .\" by the University of California, Berkeley. The name of the | |
10 | .\" University may not be used to endorse or promote products derived | |
11 | .\" from this software without specific prior written permission. | |
12 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
13 | .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
14 | .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
15 | .\" | |
16 | .\" @(#)listen.2 6.3 (Berkeley) %G% | |
cf65baf0 | 17 | .\" |
ca13daa8 | 18 | .TH LISTEN 2 "" |
cf65baf0 KM |
19 | .UC 5 |
20 | .SH NAME | |
21 | listen \- listen for connections on a socket | |
22 | .SH SYNOPSIS | |
23 | .nf | |
24 | .ft B | |
25 | listen(s, backlog) | |
26 | int s, backlog; | |
27 | .fi | |
28 | .SH DESCRIPTION | |
29 | To accept connections, a socket | |
30 | is first created with | |
31 | .IR socket (2), | |
3fa31615 MK |
32 | a willingness to accept incoming connections and |
33 | a queue limit for incoming connections are specified with | |
34 | .IR listen (2), | |
cf65baf0 KM |
35 | and then the connections are |
36 | accepted with | |
37 | .IR accept (2). | |
38 | The | |
39 | .I listen | |
40 | call applies only to sockets of type | |
41 | SOCK_STREAM | |
42 | or | |
3fa31615 | 43 | SOCK_SEQPACKET. |
cf65baf0 KM |
44 | .PP |
45 | The | |
46 | .I backlog | |
47 | parameter defines the maximum length the queue of | |
48 | pending connections may grow to. | |
49 | If a connection | |
3fa31615 MK |
50 | request arrives with the queue full the client may |
51 | receive an error with an indication of ECONNREFUSED, | |
52 | or, if the underlying protocol supports retransmission, | |
53 | the request may be ignored so that retries may succeed. | |
cf65baf0 KM |
54 | .SH "RETURN VALUE |
55 | A 0 return value indicates success; \-1 indicates an error. | |
56 | .SH "ERRORS | |
57 | The call fails if: | |
58 | .TP 20 | |
59 | [EBADF] | |
60 | The argument \fIs\fP is not a valid descriptor. | |
61 | .TP 20 | |
62 | [ENOTSOCK] | |
63 | The argument \fIs\fP is not a socket. | |
64 | .TP 20 | |
65 | [EOPNOTSUPP] | |
66 | The socket is not of a type that supports the operation \fIlisten\fP. | |
67 | .SH "SEE ALSO" | |
68 | accept(2), connect(2), socket(2) | |
69 | .SH BUGS | |
70 | The | |
71 | .I backlog | |
72 | is currently limited (silently) to 5. |