1listen(3SOCKET) Sockets Library Functions listen(3SOCKET)
2
3
4
6 listen - listen for connections on a socket
7
9 cc [ flag ... ] file ... -lsocket -lnsl [ library ... ]
10 #include <sys/types.h>
11 #include <sys/socket.h>
12
13 int listen(int s, int backlog);
14
15
17 To accept connections, a socket is first created with socket(3SOCKET),
18 a backlog for incoming connections is specified with listen() and then
19 the connections are accepted with accept(3SOCKET). The listen() call
20 applies only to sockets of type SOCK_STREAM or SOCK_SEQPACKET.
21
22
23 The backlog parameter defines the maximum length the queue of pending
24 connections may grow to.
25
26
27 If a connection request arrives with the queue full, the client will
28 receive an error with an indication of ECONNREFUSED for AF_UNIX sock‐
29 ets. If the underlying protocol supports retransmission, the connec‐
30 tion request may be ignored so that retries may succeed. For AF_INET
31 and AF_INET6sockets, the TCP will retry the connection. If the backlog
32 is not cleared by the time the tcp times out, the connect will fail
33 with ETIMEDOUT.
34
36 A 0 return value indicates success; −1 indicates an error.
37
39 The call fails if:
40
41 EBADF The argument s is not a valid file descriptor.
42
43
44 ENOTSOCK The argument s is not a socket.
45
46
47 EOPNOTSUPP The socket is not of a type that supports the operation
48 listen().
49
50
52 See attributes(5) for descriptions of the following attributes:
53
54
55
56
57 ┌─────────────────────────────┬─────────────────────────────┐
58 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
59 ├─────────────────────────────┼─────────────────────────────┤
60 │MT-Level │Safe │
61 └─────────────────────────────┴─────────────────────────────┘
62
64 accept(3SOCKET), connect(3SOCKET), socket(3SOCKET), attributes(5),
65 socket.h(3HEAD)
66
68 There is currently no backlog limit.
69
70
71
72SunOS 5.11 8 Nov 1999 listen(3SOCKET)