OSDN Git Service

Convert release and draft pages to UTF-8.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man2 / listen.2
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.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
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.
20 .\"
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
31 .\" SUCH DAMAGE.
32 .\"
33 .\"     $Id: listen.2,v 1.4 2001/05/19 02:09:20 hanataka Exp $
34 .\"
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>
41 .\"
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
50 .\"
51 .\"WORD:        socket                  ソケット
52 .\"WORD:        listen                  監視
53 .\"WORD:        queue                   キュー
54 .\"WORD:        descriptor              ディスクリプター
55 .\"
56 .TH LISTEN 2 2008-11-20 "Linux" "Linux Programmer's Manual"
57 .\"O .SH NAME
58 .SH 名前
59 .\"O listen \- listen for connections on a socket
60 listen \- ソケット(socket)上の接続を待つ
61 .\"O .SH SYNOPSIS
62 .SH 書式
63 .nf
64 .\"O .BR "#include <sys/types.h>" "          /* See NOTES */"
65 .BR "#include <sys/types.h>" "          /* 「注意」参照 */"
66 .br
67 .B #include <sys/socket.h>
68 .sp
69 .BI "int listen(int " sockfd ", int " backlog );
70 .fi
71 .\"O .SH DESCRIPTION
72 .SH 説明
73 .\"O .BR listen ()
74 .\"O marks the socket referred to by
75 .\"O .I sockfd
76 .\"O as a passive socket, that is, as a socket that will
77 .\"O be used to accept incoming connection requests using
78 .\"O .BR accept (2).
79 .BR listen ()
80
81 .I sockfd
82 が参照するソケットを接続待ちソケット (passive socket) として印をつける。
83 接続待ちソケットとは、
84 .BR accept (2)
85 を使って到着した接続要求を受け付けるのに使用されるソケットである。
86
87 .\"O The
88 .\"O .I sockfd
89 .\"O argument is a file descriptor that refers to a socket of type
90 .\"O .B SOCK_STREAM
91 .\"O or
92 .\"O .BR SOCK_SEQPACKET .
93 .I sockfd
94 引き数は、
95 .B SOCK_STREAM
96 型か
97 .B SOCK_SEQPACKET
98 型のソケットを参照するファイルディスクリプタである。
99
100 .\"O The
101 .\"O .I backlog
102 .\"O argument defines the maximum length
103 .\"O to which the queue of pending connections for
104 .\"O .I sockfd
105 .\"O may grow.
106 .\"O If a connection request arrives when the queue is full, the client
107 .\"O may receive an error with an indication of
108 .\"O .B ECONNREFUSED
109 .\"O or, if the underlying protocol supports retransmission, the request may be
110 .\"O ignored so that a later reattempt at connection succeeds.
111 .I backlog
112 引き数は、
113 .I sockfd
114 についての保留中の接続のキューの最大長を指定する。
115 キューがいっぱいの状態で接続要求が到着すると、クライアントは
116 .B ECONNREFUSED
117 というエラーを受け取る。下位層のプロトコルが再送信をサポート
118 していれば、要求は無視され、これ以降の接続要求の再送信が成功するかもしれない。
119 .\"O .SH "RETURN VALUE"
120 .SH 返り値
121 .\"O On success, zero is returned.
122 .\"O On error, \-1 is returned, and
123 .\"O .I errno
124 .\"O is set appropriately.
125 成功時には0を返す。エラー時には \-1を返し、
126 .I errno
127 を適切に設定する。
128 .\"O .SH ERRORS
129 .SH エラー
130 .\"O .TP
131 .\"O .B EADDRINUSE
132 .\"O Another socket is already listening on the same port.
133 .TP
134 .B EADDRINUSE
135 別のソケットが既に同じポートを listen している。
136 .TP
137 .B EBADF
138 .\"O The argument
139 .\"O .I sockfd
140 .\"O is not a valid descriptor.
141 引き数
142 .I sockfd
143 は有効なディスクリプターではない。
144 .TP
145 .B ENOTSOCK
146 .\"O The argument
147 .\"O .I sockfd
148 .\"O is not a socket.
149 引き数
150 .I sockfd
151 はソケットではない。
152 .TP
153 .B EOPNOTSUPP
154 .\"O The socket is not of a type that supports the
155 .\"O .BR listen ()
156 .\"O operation.
157 ソケットは
158 .BR listen ()
159 がサポートしている型ではない。
160 .\"O .SH "CONFORMING TO"
161 .SH 準拠
162 .\"O 4.4BSD, POSIX.1-2001.
163 .\"O The
164 .\"O .B listen
165 .\"O function call first appeared in 4.2BSD.
166 4.4BSD, POSIX.1-2001.
167 .BR listen ()
168 関数は 4.2BSDで初めて実装された。
169 .\"O .SH NOTES
170 .SH 注意
171 .\"O To accept connections, the following steps are performed:
172 接続を受け付けるには、以下の処理が実行される。
173 .RS 4
174 .IP 1. 4
175 .\"O A socket is created with
176 .\"O .BR socket (2).
177 .BR socket (2)
178 でソケットを作成する。
179 .IP 2.
180 .\"O The socket is bound to a local address using
181 .\"O .BR bind (2),
182 .\"O so that other sockets may be
183 .\"O .BR connect (2)ed
184 .\"O to it.
185 .BR bind (2)
186 を使ってソケットにローカルアドレスを割り当てて、
187 他のソケットがこのソケットに
188 .BR connect (2)
189 できるようにする。
190 .IP 3.
191 .\"O A willingness to accept incoming connections and a queue limit for incoming
192 .\"O connections are specified with
193 .\"O .BR listen ().
194 .BR listen ()
195 を使って、接続要求を受け付ける意志と接続要求を入れるキュー長を指定する。
196 .IP 4.
197 .\"O Connections are accepted with
198 .\"O .BR accept (2).
199 .BR accept (2)
200 を使って接続を受け付ける。
201 .RE
202 .PP
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.
208 POSIX.1-2001 では
209 .I <sys/types.h>
210 のインクルードは必須とされておらず、
211 Linux ではこのヘッダファイルは必要ではない。
212 しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダファイルが
213 必要であり、移植性が必要なアプリケーションではこのファイルを
214 インクルードするのが賢明であろう。
215
216 .\"O The behavior of the
217 .\"O .I backlog
218 .\"O argument on TCP sockets changed with Linux 2.2.
219 TCP ソケットでの
220 .I backlog
221 引き数の振る舞いは Linux 2.2 で変更された。
222 .\"O Now it specifies the queue length for
223 .\"O .I completely
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 .
229 現在ではこの引き数は、
230 受け付けられるのを待っている、
231 .I 完全に
232 確立されたソケットのキューの長さを指定する。
233 以前は不完全な接続要求の数であったが、これを置き換えた。
234 不完全なソケットのキューの最大長は
235 .I /proc/sys/net/ipv4/tcp_max_syn_backlog
236 を用いて設定できる。
237 .\"O When syncookies are enabled there is no logical maximum
238 .\"O  length and this setting is ignored.
239 .\"O See
240 .\"O .BR tcp (7)
241 .\"O for more information.
242 syncookie が有効になっている場合、
243 論理的な最大長は存在せず、この設定は無視される。
244
245 .\"O If the
246 .\"O .I backlog
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,
252 .\"O .BR SOMAXCONN ,
253 .\"O with the value 128.
254 .I backlog
255 引き数が
256 .I /proc/sys/net/core/somaxconn
257 の値よりも大きければ、
258 .I backlog
259 の値は暗黙のうちにこの値に切り詰められる。
260 このファイルのデフォルト値は 128 である。
261 バージョン 2.4.5 以前のカーネルでは、この上限値は
262 コード埋め込みの固定値
263 .B SOMAXCONN
264 であり、その値は 128 であった。
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) に頼ってはいけない。
272 .\"O .SH EXAMPLE
273 .SH 例
274 .\"O See
275 .\"O .BR bind (2).
276 .BR bind (2)
277 参照。
278 .\"O .SH "SEE ALSO"
279 .SH 関連項目
280 .BR accept (2),
281 .BR bind (2),
282 .BR connect (2),
283 .BR socket (2),
284 .BR socket (7)