OSDN Git Service

(split) LDP: Update the version to 3.53 in PO files
[linuxjm/LDP_man-pages.git] / release / 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 .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\"    must display the following acknowledgement:
16 .\"     This product includes software developed by the University of
17 .\"     California, Berkeley and its contributors.
18 .\" 4. Neither the name of the University nor the names of its contributors
19 .\"    may be used to endorse or promote products derived from this software
20 .\"    without specific prior written permission.
21 .\"
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" SUCH DAMAGE.
33 .\" %%%LICENSE_END
34 .\"
35 .\"     $Id: listen.2,v 1.6 1999/05/18 14:10:32 freitag Exp $
36 .\"
37 .\" Modified Fri Jul 23 22:07:54 1993 by Rik Faith <faith@cs.unc.edu>
38 .\" Modified 950727 by aeb, following a suggestion by Urs Thuermann
39 .\" <urs@isnogud.escape.de>
40 .\" Modified Tue Oct 22 08:11:14 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
41 .\" Modified 1998 by Andi Kleen
42 .\" Modified 11 May 2001 by Sam Varshavchik <mrsam@courier-mta.com>
43 .\"
44 .\"
45 .\"*******************************************************************
46 .\"
47 .\" This file was generated with po4a. Translate the source file.
48 .\"
49 .\"*******************************************************************
50 .TH LISTEN 2 2008\-11\-20 Linux "Linux Programmer's Manual"
51 .SH 名前
52 listen \- ソケット(socket)上の接続を待つ
53 .SH 書式
54 .nf
55 \fB#include <sys/types.h>\fP          /* 「注意」参照 */
56 .br
57 \fB#include <sys/socket.h>\fP
58 .sp
59 \fBint listen(int \fP\fIsockfd\fP\fB, int \fP\fIbacklog\fP\fB);\fP
60 .fi
61 .SH 説明
62 \fBlisten\fP()  は \fIsockfd\fP が参照するソケットを接続待ちソケット (passive socket) として印をつける。
63 接続待ちソケットとは、 \fBaccept\fP(2)  を使って到着した接続要求を受け付けるのに使用されるソケットである。
64
65 \fIsockfd\fP 引き数は、 \fBSOCK_STREAM\fP 型か \fBSOCK_SEQPACKET\fP
66 型のソケットを参照するファイルディスクリプタである。
67
68 \fIbacklog\fP 引き数は、 \fIsockfd\fP についての保留中の接続のキューの最大長を指定する。
69 キューがいっぱいの状態で接続要求が到着すると、クライアントは \fBECONNREFUSED\fP
70 というエラーを受け取る。下位層のプロトコルが再送信をサポート していれば、要求は無視され、これ以降の接続要求の再送信が成功するかもしれない。
71 .SH 返り値
72 成功した場合にはゼロが返される。エラー時には \-1 が返され、 \fIerrno\fP が適切に設定される。
73 .SH エラー
74 .TP 
75 \fBEADDRINUSE\fP
76 別のソケットが既に同じポートを listen している。
77 .TP 
78 \fBEBADF\fP
79 引き数 \fIsockfd\fP は有効なディスクリプターでない。
80 .TP 
81 \fBENOTSOCK\fP
82 引き数 \fIsockfd\fP はソケットではない。
83 .TP 
84 \fBEOPNOTSUPP\fP
85 ソケットは \fBlisten\fP()  がサポートしている型ではない。
86 .SH 準拠
87 4.4BSD, POSIX.1\-2001.  \fBlisten\fP()  関数は 4.2BSDで初めて実装された。
88 .SH 注意
89 接続を受け付けるには、以下の処理が実行される。
90 .RS 4
91 .IP 1. 4
92 \fBsocket\fP(2)  でソケットを作成する。
93 .IP 2.
94 \fBbind\fP(2)  を使ってソケットにローカルアドレスを割り当てて、 他のソケットがこのソケットに \fBconnect\fP(2)  できるようにする。
95 .IP 3.
96 \fBlisten\fP()  を使って、接続要求を受け付ける意志と接続要求を入れるキュー長を指定する。
97 .IP 4.
98 \fBaccept\fP(2)  を使って接続を受け付ける。
99 .RE
100 .PP
101 POSIX.1\-2001 では \fI<sys/types.h>\fP のインクルードは必須とされておらず、 Linux
102 ではこのヘッダファイルは必要ではない。 しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダファイルが
103 必要であり、移植性が必要なアプリケーションではこのファイルを インクルードするのが賢明であろう。
104
105 TCP ソケットでの \fIbacklog\fP 引き数の振る舞いは Linux 2.2 で変更された。 現在ではこの引き数は、
106 受け付けられるのを待っている、 \fI完全に\fP 確立されたソケットのキューの長さを指定する。 以前は不完全な接続要求の数であったが、これを置き換えた。
107 不完全なソケットのキューの最大長は \fI/proc/sys/net/ipv4/tcp_max_syn_backlog\fP を用いて設定できる。
108 syncookie が有効になっている場合、 論理的な最大長は存在せず、この設定は無視される。
109
110 .\" The following is now rather historic information (MTK, Jun 05)
111 .\" Don't rely on this value in portable applications since BSD
112 .\" (and some BSD-derived systems) limit the backlog to 5.
113 \fIbacklog\fP 引き数が \fI/proc/sys/net/core/somaxconn\fP の値よりも大きければ、 \fIbacklog\fP
114 の値は暗黙のうちにこの値に切り詰められる。 このファイルのデフォルト値は 128 である。 バージョン 2.4.5 以前のカーネルでは、この上限値は
115 コード埋め込みの固定値 \fBSOMAXCONN\fP であり、その値は 128 であった。
116 .SH 例
117 \fBbind\fP(2)  参照。
118 .SH 関連項目
119 \fBaccept\fP(2), \fBbind\fP(2), \fBconnect\fP(2), \fBsocket\fP(2), \fBsocket\fP(7)
120 .SH この文書について
121 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
122 である。プロジェクトの説明とバグ報告に関する情報は
123 http://www.kernel.org/doc/man\-pages/ に書かれている。