1 .\" Copyright (c) 1983, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" From: @(#)listen.2 8.2 (Berkeley) 12/11/93
36 .Nd listen for connections on a socket
42 .Fn listen "int s" "int backlog"
44 To accept connections, a socket
47 a willingness to accept incoming connections and
48 a queue limit for incoming connections are specified with
50 and then the connections are
55 system call applies only to sockets of type
62 argument defines the maximum length the queue of
63 pending connections may grow to.
64 The real maximum queue length will be 1.5 times more than the value
70 system call on the listening socket allows the caller to change the maximum
71 queue length using a new
75 request arrives with the queue full the client may
76 receive an error with an indication of
78 or, in the case of TCP, the connection will be
81 Current queue lengths of listening sockets can be queried using
87 and the introduction of the syncache,
90 argument also determined the length of the incomplete
91 connection queue, which held TCP sockets in the process
92 of completing TCP's 3-way handshake.
93 These incomplete connections
94 are now held entirely in the syncache, which is unaffected by
98 values to help handle denial
99 of service attacks are no longer necessary.
104 .Va kern.ipc.soacceptqueue
105 specifies a hard limit on
107 if a value greater than
108 .Va kern.ipc.soacceptqueue
109 or less than zero is specified,
111 is silently forced to
112 .Va kern.ipc.soacceptqueue .
113 .Sh INTERACTION WITH ACCEPT FILTERS
114 When accept filtering is used on a socket, a second queue will
115 be used to hold sockets that have connected, but have not yet
116 met their accept filtering criteria.
117 Once the criteria has been
118 met, these sockets will be moved over into the completed connection
121 If this secondary queue is full and a
122 new connection comes in, the oldest socket which has not yet met
123 its accept filter criteria will be terminated.
125 This secondary queue, like the primary listen queue, is sized
140 is not a valid descriptor.
141 .It Bq Er EDESTADDRREQ
142 The socket is not bound to a local address, and the protocol does not
143 support listening on an unbound socket.
145 The socket is already connected, or in the process of being connected.
151 The socket is not of a type that supports the operation
165 system call appeared in
167 The ability to configure the maximum
169 at run-time, and to use a negative
171 to request the maximum allowable value, was introduced in
174 .Va kern.ipc.somaxconn
176 has been replaced with
177 .Va kern.ipc.soacceptqueue
180 to prevent confusion about its actual functionality.
183 .Va kern.ipc.somaxconn
184 is still available but hidden from a
186 -a output so that existing applications and scripts continue to work.