1listen(3XNET) X/Open Networking Services Library Functions listen(3XNET)
2
3
4
6 listen - listen for socket connections and limit the queue of incoming
7 connections
8
10 cc [ flag ... ] file ... -lxnet [ library ... ]
11 #include <sys/socket.h>
12
13 int listen(int socket, int backlog);
14
15
17 The listen() function marks a connection-mode socket, specified by the
18 socket argument, as accepting connections, and limits the number of
19 outstanding connections in the socket's listen queue to the value spec‐
20 ified by the backlog argument.
21
22
23 If listen() is called with a backlog argument value that is less than
24 0, the function sets the length of the socket's listen queue to 0.
25
26
27 The implementation may include incomplete connections in the queue sub‐
28 ject to the queue limit. The implementation may also increase the spec‐
29 ified queue limit internally if it includes such incomplete connections
30 in the queue subject to this limit.
31
32
33 Implementations may limit the length of the socket's listen queue. If
34 backlog exceeds the implementation-dependent maximum queue length, the
35 length of the socket's listen queue will be set to the maximum sup‐
36 ported value.
37
38
39 The socket in use may require the process to have appropriate privi‐
40 leges to use the listen() function.
41
43 Upon successful completions, listen() returns 0. Otherwise, −1 is
44 returned and errno is set to indicate the error.
45
47 The listen() function will fail if:
48
49 EBADF The socket argument is not a valid file descriptor.
50
51
52 EDESTADDRREQ The socket is not bound to a local address, and the
53 protocol does not support listening on an unbound
54 socket.
55
56
57 EINVAL The socket is already connected.
58
59
60 ENOTSOCK The socket argument does not refer to a socket.
61
62
63 EOPNOTSUPP The socket protocol does not support listen().
64
65
66
67 The listen() function may fail if:
68
69 EACCES The calling process does not have the appropriate privi‐
70 leges.
71
72
73 EINVAL The socket has been shut down.
74
75
76 ENOBUFS Insufficient resources are available in the system to com‐
77 plete the call.
78
79
81 See attributes(5) for descriptions of the following attributes:
82
83
84
85
86 ┌─────────────────────────────┬─────────────────────────────┐
87 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
88 ├─────────────────────────────┼─────────────────────────────┤
89 │Interface Stability │Standard │
90 ├─────────────────────────────┼─────────────────────────────┤
91 │MT-Level │MT-Safe │
92 └─────────────────────────────┴─────────────────────────────┘
93
95 accept(3XNET), connect(3XNET), socket(3XNET), attributes(5), stan‐
96 dards(5)
97
98
99
100SunOS 5.11 10 Jun 2002 listen(3XNET)