1 .\" Copyright (c) 1983, 1991 The Regents of the University of California.
2 .\" and Copyright (C) 2007, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
13 .\" 3. All advertising materials mentioning features or use of this software
14 .\" must display the following acknowledgement:
15 .\" This product includes software developed by the University of
16 .\" California, Berkeley and its contributors.
17 .\" 4. Neither the name of the University nor the names of its contributors
18 .\" may be used to endorse or promote products derived from this software
19 .\" without specific prior written permission.
21 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" $Id: listen.2,v 1.4 2001/05/19 02:09:20 hanataka Exp $
35 .\" Modified Fri Jul 23 22:07:54 1993 by Rik Faith <faith@cs.unc.edu>
36 .\" Modified 950727 by aeb, following a suggestion by Urs Thuermann
37 .\" <urs@isnogud.escape.de>
38 .\" Modified Tue Oct 22 08:11:14 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
39 .\" Modified 1998 by Andi Kleen
40 .\" Modified 11 May 2001 by Sam Varshavchik <mrsam@courier-mta.com>
42 .\" Japanese Version Copyright (c) 1998 Shinya HANATAKA, Takeshi Hakamada
43 .\" all rights reserved.
44 .\" Translated 1998-04-06,Shinya HANATAKA <shinya@abyss.rim.or.jp>
45 .\" and Takeshi Hakamada <hakamada@nsg.sgi.com>
46 .\" Modified 2000-01-13, Kentaro Shirakata <argrath@yo.rim.or.jp>
47 .\" Modified 2001-05-19, Shinya HANATAKA <shinya@abyss.rim.or.jp>
48 .\" Updated 2007-07-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.58
49 .\" Updated 2008-02-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.77
54 .\"WORD: descriptor ディスクリプター
56 .TH LISTEN 2 2008-11-20 "Linux" "Linux Programmer's Manual"
59 .\"O listen \- listen for connections on a socket
60 listen \- ソケット(socket)上の接続を待つ
64 .\"O .BR "#include <sys/types.h>" " /* See NOTES */"
65 .BR "#include <sys/types.h>" " /* 「注意」参照 */"
67 .B #include <sys/socket.h>
69 .BI "int listen(int " sockfd ", int " backlog );
74 .\"O marks the socket referred to by
76 .\"O as a passive socket, that is, as a socket that will
77 .\"O be used to accept incoming connection requests using
82 が参照するソケットを接続待ちソケット (passive socket) として印をつける。
85 を使って到着した接続要求を受け付けるのに使用されるソケットである。
89 .\"O argument is a file descriptor that refers to a socket of type
92 .\"O .BR SOCK_SEQPACKET .
98 型のソケットを参照するファイルディスクリプタである。
102 .\"O argument defines the maximum length
103 .\"O to which the queue of pending connections for
106 .\"O If a connection request arrives when the queue is full, the client
107 .\"O may receive an error with an indication of
109 .\"O or, if the underlying protocol supports retransmission, the request may be
110 .\"O ignored so that a later reattempt at connection succeeds.
114 についての保留中の接続のキューの最大長を指定する。
115 キューがいっぱいの状態で接続要求が到着すると、クライアントは
117 というエラーを受け取る。下位層のプロトコルが再送信をサポート
118 していれば、要求は無視され、これ以降の接続要求の再送信が成功するかもしれない。
119 .\"O .SH "RETURN VALUE"
121 .\"O On success, zero is returned.
122 .\"O On error, \-1 is returned, and
124 .\"O is set appropriately.
125 成功時には0を返す。エラー時には \-1を返し、
132 .\"O Another socket is already listening on the same port.
135 別のソケットが既に同じポートを listen している。
140 .\"O is not a valid descriptor.
148 .\"O is not a socket.
154 .\"O The socket is not of a type that supports the
160 .\"O .SH "CONFORMING TO"
162 .\"O 4.4BSD, POSIX.1-2001.
165 .\"O function call first appeared in 4.2BSD.
166 4.4BSD, POSIX.1-2001.
171 .\"O To accept connections, the following steps are performed:
172 接続を受け付けるには、以下の処理が実行される。
175 .\"O A socket is created with
180 .\"O The socket is bound to a local address using
182 .\"O so that other sockets may be
183 .\"O .BR connect (2)ed
186 を使ってソケットにローカルアドレスを割り当てて、
191 .\"O A willingness to accept incoming connections and a queue limit for incoming
192 .\"O connections are specified with
195 を使って、接続要求を受け付ける意志と接続要求を入れるキュー長を指定する。
197 .\"O Connections are accepted with
203 .\"O POSIX.1-2001 does not require the inclusion of
204 .\"O .IR <sys/types.h> ,
205 .\"O and this header file is not required on Linux.
206 .\"O However, some historical (BSD) implementations required this header
207 .\"O file, and portable applications are probably wise to include it.
211 Linux ではこのヘッダファイルは必要ではない。
212 しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダファイルが
213 必要であり、移植性が必要なアプリケーションではこのファイルを
216 .\"O The behavior of the
218 .\"O argument on TCP sockets changed with Linux 2.2.
221 引き数の振る舞いは Linux 2.2 で変更された。
222 .\"O Now it specifies the queue length for
224 .\"O established sockets waiting to be accepted,
225 .\"O instead of the number of incomplete connection requests.
226 .\"O The maximum length of the queue for incomplete sockets
227 .\"O can be set using
228 .\"O .IR /proc/sys/net/ipv4/tcp_max_syn_backlog .
232 確立されたソケットのキューの長さを指定する。
233 以前は不完全な接続要求の数であったが、これを置き換えた。
235 .I /proc/sys/net/ipv4/tcp_max_syn_backlog
237 .\"O When syncookies are enabled there is no logical maximum
238 .\"O length and this setting is ignored.
241 .\"O for more information.
242 syncookie が有効になっている場合、
243 論理的な最大長は存在せず、この設定は無視される。
247 .\"O argument is greater than the value in
248 .\"O .IR /proc/sys/net/core/somaxconn ,
249 .\"O then it is silently truncated to that value;
250 .\"O the default value in this file is 128.
251 .\"O In kernels before 2.4.25, this limit was a hard coded value,
253 .\"O with the value 128.
256 .I /proc/sys/net/core/somaxconn
259 の値は暗黙のうちにこの値に切り詰められる。
260 このファイルのデフォルト値は 128 である。
261 バージョン 2.4.5 以前のカーネルでは、この上限値は
265 .\"O .\" The following is now rather historic information (MTK, Jun 05)
266 .\"O .\" Don't rely on this value in portable applications since BSD
267 .\"O .\" (and some BSD-derived systems) limit the backlog to 5.
268 .\" 以下は、今では古い情報である。(MTK, Jun 05)
269 .\" BSD (と、いくつかの BSD から派生したシステム)では backlog を 5 に
270 .\" 制限しているので、移植性を考慮したアプリケーションでは
271 .\" この値 (SOMAXCONN) に頼ってはいけない。