OSDN Git Service

Update drafts for LDP 3.67
[linuxjm/LDP_man-pages.git] / draft / man2 / listen.2
index 7aca4a5..275b92a 100644 (file)
@@ -2,6 +2,7 @@
 .\" and Copyright (C) 2007, Michael Kerrisk <mtk.manpages@gmail.com>
 .\" All rights reserved.
 .\"
 .\" and Copyright (C) 2007, Michael Kerrisk <mtk.manpages@gmail.com>
 .\" All rights reserved.
 .\"
+.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
 .\" are met:
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
 .\" are met:
@@ -29,8 +30,9 @@
 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
+.\" %%%LICENSE_END
 .\"
 .\"
-.\"     $Id: listen.2,v 1.4 2001/05/19 02:09:20 hanataka Exp $
+.\"     $Id: listen.2,v 1.6 1999/05/18 14:10:32 freitag Exp $
 .\"
 .\" Modified Fri Jul 23 22:07:54 1993 by Rik Faith <faith@cs.unc.edu>
 .\" Modified 950727 by aeb, following a suggestion by Urs Thuermann
 .\"
 .\" Modified Fri Jul 23 22:07:54 1993 by Rik Faith <faith@cs.unc.edu>
 .\" Modified 950727 by aeb, following a suggestion by Urs Thuermann
 .\" Modified 1998 by Andi Kleen
 .\" Modified 11 May 2001 by Sam Varshavchik <mrsam@courier-mta.com>
 .\"
 .\" Modified 1998 by Andi Kleen
 .\" Modified 11 May 2001 by Sam Varshavchik <mrsam@courier-mta.com>
 .\"
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
 .\" Japanese Version Copyright (c) 1998 Shinya HANATAKA, Takeshi Hakamada
 .\"         all rights reserved.
 .\" Translated 1998-04-06,Shinya HANATAKA <shinya@abyss.rim.or.jp>
 .\" Japanese Version Copyright (c) 1998 Shinya HANATAKA, Takeshi Hakamada
 .\"         all rights reserved.
 .\" Translated 1998-04-06,Shinya HANATAKA <shinya@abyss.rim.or.jp>
 .\" Updated 2007-07-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.58
 .\" Updated 2008-02-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.77
 .\"
 .\" Updated 2007-07-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.58
 .\" Updated 2008-02-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.77
 .\"
-.\"WORD:       socket                  ¥½¥±¥Ã¥È
-.\"WORD:       listen                  ´Æ»ë
-.\"WORD:       queue                   ¥­¥å¡¼
-.\"WORD:       descriptor              ¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼
-.\"
-.TH LISTEN 2 2008-11-20 "Linux" "Linux Programmer's Manual"
-.\"O .SH NAME
-.SH Ì¾Á°
-.\"O listen \- listen for connections on a socket
-listen \- ¥½¥±¥Ã¥È(socket)¾å¤ÎÀܳ¤òÂÔ¤Ä
-.\"O .SH SYNOPSIS
-.SH ½ñ¼°
+.TH LISTEN 2 2014\-05\-10 Linux "Linux Programmer's Manual"
+.SH 名前
+listen \- ソケット(socket)上の接続を待つ
+.SH 書式
 .nf
 .nf
-.\"O .BR "#include <sys/types.h>" "          /* See NOTES */"
-.BR "#include <sys/types.h>" "          /* ¡ÖÃí°Õ¡×»²¾È */"
+\fB#include <sys/types.h>\fP          /* 「注意」参照 */
 .br
 .br
-.B #include <sys/socket.h>
+\fB#include <sys/socket.h>\fP
 .sp
 .sp
-.BI "int listen(int " sockfd ", int " backlog );
+\fBint listen(int \fP\fIsockfd\fP\fB, int \fP\fIbacklog\fP\fB);\fP
 .fi
 .fi
-.\"O .SH DESCRIPTION
-.SH ÀâÌÀ
-.\"O .BR listen ()
-.\"O marks the socket referred to by
-.\"O .I sockfd
-.\"O as a passive socket, that is, as a socket that will
-.\"O be used to accept incoming connection requests using
-.\"O .BR accept (2).
-.BR listen ()
-¤Ï
-.I sockfd
-¤¬»²¾È¤¹¤ë¥½¥±¥Ã¥È¤òÀܳÂÔ¤Á¥½¥±¥Ã¥È (passive socket) ¤È¤·¤Æ°õ¤ò¤Ä¤±¤ë¡£
-ÀܳÂÔ¤Á¥½¥±¥Ã¥È¤È¤Ï¡¢
-.BR accept (2)
-¤ò»È¤Ã¤ÆÅþÃ夷¤¿ÀܳÍ×µá¤ò¼õ¤±ÉÕ¤±¤ë¤Î¤Ë»ÈÍѤµ¤ì¤ë¥½¥±¥Ã¥È¤Ç¤¢¤ë¡£
+.SH 説明
+\fBlisten\fP()  は \fIsockfd\fP が参照するソケットを接続待ちソケット (passive socket) として印をつける。
+接続待ちソケットとは、 \fBaccept\fP(2)  を使って到着した接続要求を受け付けるのに使用されるソケットである。
 
 
-.\"O The
-.\"O .I sockfd
-.\"O argument is a file descriptor that refers to a socket of type
-.\"O .B SOCK_STREAM
-.\"O or
-.\"O .BR SOCK_SEQPACKET .
-.I sockfd
-°ú¤­¿ô¤Ï¡¢
-.B SOCK_STREAM
-·¿¤«
-.B SOCK_SEQPACKET
-·¿¤Î¥½¥±¥Ã¥È¤ò»²¾È¤¹¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤¢¤ë¡£
+\fIsockfd\fP 引き数は、 \fBSOCK_STREAM\fP 型か \fBSOCK_SEQPACKET\fP
+型のソケットを参照するファイルディスクリプタである。
 
 
-.\"O The
-.\"O .I backlog
-.\"O argument defines the maximum length
-.\"O to which the queue of pending connections for
-.\"O .I sockfd
-.\"O may grow.
-.\"O If a connection request arrives when the queue is full, the client
-.\"O may receive an error with an indication of
-.\"O .B ECONNREFUSED
-.\"O or, if the underlying protocol supports retransmission, the request may be
-.\"O ignored so that a later reattempt at connection succeeds.
-.I backlog
-°ú¤­¿ô¤Ï¡¢
-.I sockfd
-¤Ë¤Ä¤¤¤Æ¤ÎÊÝαÃæ¤ÎÀܳ¤Î¥­¥å¡¼¤ÎºÇÂçŤò»ØÄꤹ¤ë¡£
-¥­¥å¡¼¤¬¤¤¤Ã¤Ñ¤¤¤Î¾õÂÖ¤ÇÀܳÍ׵᤬ÅþÃ夹¤ë¤È¡¢¥¯¥é¥¤¥¢¥ó¥È¤Ï
-.B ECONNREFUSED
-¤È¤¤¤¦¥¨¥é¡¼¤ò¼õ¤±¼è¤ë¡£²¼°ÌÁؤΥץí¥È¥³¥ë¤¬ºÆÁ÷¿®¤ò¥µ¥Ý¡¼¥È
-¤·¤Æ¤¤¤ì¤Ð¡¢Í×µá¤Ï̵»ë¤µ¤ì¡¢¤³¤ì°Ê¹ß¤ÎÀܳÍ×µá¤ÎºÆÁ÷¿®¤¬À®¸ù¤¹¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
-.\"O .SH "RETURN VALUE"
-.SH ÊÖ¤êÃÍ
-.\"O On success, zero is returned.
-.\"O On error, \-1 is returned, and
-.\"O .I errno
-.\"O is set appropriately.
-À®¸ù»þ¤Ë¤Ï0¤òÊÖ¤¹¡£¥¨¥é¡¼»þ¤Ë¤Ï \-1¤òÊÖ¤·¡¢
-.I errno
-¤òŬÀÚ¤ËÀßÄꤹ¤ë¡£
-.\"O .SH ERRORS
-.SH ¥¨¥é¡¼
-.\"O .TP
-.\"O .B EADDRINUSE
-.\"O Another socket is already listening on the same port.
-.TP
-.B EADDRINUSE
-Ê̤Υ½¥±¥Ã¥È¤¬´û¤ËƱ¤¸¥Ý¡¼¥È¤ò listen ¤·¤Æ¤¤¤ë¡£
-.TP
-.B EBADF
-.\"O The argument
-.\"O .I sockfd
-.\"O is not a valid descriptor.
-°ú¤­¿ô
-.I sockfd
-¤ÏÍ­¸ú¤Ê¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤Ç¤Ï¤Ê¤¤¡£
-.TP
-.B ENOTSOCK
-.\"O The argument
-.\"O .I sockfd
-.\"O is not a socket.
-°ú¤­¿ô
-.I sockfd
-¤Ï¥½¥±¥Ã¥È¤Ç¤Ï¤Ê¤¤¡£
-.TP
-.B EOPNOTSUPP
-.\"O The socket is not of a type that supports the
-.\"O .BR listen ()
-.\"O operation.
-¥½¥±¥Ã¥È¤Ï
-.BR listen ()
-¤¬¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë·¿¤Ç¤Ï¤Ê¤¤¡£
-.\"O .SH "CONFORMING TO"
-.SH ½àµò
-.\"O 4.4BSD, POSIX.1-2001.
-.\"O The
-.\"O .B listen
-.\"O function call first appeared in 4.2BSD.
-4.4BSD, POSIX.1-2001.
-.BR listen ()
-´Ø¿ô¤Ï 4.2BSD¤Ç½é¤á¤Æ¼ÂÁõ¤µ¤ì¤¿¡£
-.\"O .SH NOTES
-.SH Ãí°Õ
-.\"O To accept connections, the following steps are performed:
-Àܳ¤ò¼õ¤±ÉÕ¤±¤ë¤Ë¤Ï¡¢°Ê²¼¤Î½èÍý¤¬¼Â¹Ô¤µ¤ì¤ë¡£
+\fIbacklog\fP 引き数は、 \fIsockfd\fP についての保留中の接続のキューの最大長を指定する。
+キューがいっぱいの状態で接続要求が到着すると、クライアントは \fBECONNREFUSED\fP
+というエラーを受け取る。下位層のプロトコルが再送信をサポート していれば、要求は無視され、これ以降の接続要求の再送信が成功するかもしれない。
+.SH 返り値
+成功した場合にはゼロが返される。エラー時には \-1 が返され、 \fIerrno\fP が適切に設定される。
+.SH エラー
+.TP 
+\fBEADDRINUSE\fP
+別のソケットが既に同じポートを listen している。
+.TP 
+\fBEADDRINUSE\fP
+(インターネットドメインソケットの場合) \fIsockfd\fP が参照するソケットがそれ以前にアドレスにバインドされておらず、
+そのソケットに一時ポートをバインドしようとした際に、 一時ポートとして使用する範囲のポート番号がすべて使用中であった。 \fBip\fP(7) の
+\fI/proc/sys/net/ipv4/ip_local_port_range\fP の議論を参照のこと。
+.TP 
+\fBEBADF\fP
+引き数 \fIsockfd\fP は有効なディスクリプターでない。
+.TP 
+\fBENOTSOCK\fP
+引き数 \fIsockfd\fP はソケットではない。
+.TP 
+\fBEOPNOTSUPP\fP
+ソケットは \fBlisten\fP()  がサポートしている型ではない。
+.SH 準拠
+4.4BSD, POSIX.1\-2001.  \fBlisten\fP()  関数は 4.2BSDで初めて実装された。
+.SH 注意
+接続を受け付けるには、以下の処理が実行される。
 .RS 4
 .IP 1. 4
 .RS 4
 .IP 1. 4
-.\"O A socket is created with
-.\"O .BR socket (2).
-.BR socket (2)
-¤Ç¥½¥±¥Ã¥È¤òºîÀ®¤¹¤ë¡£
+\fBsocket\fP(2)  でソケットを作成する。
 .IP 2.
 .IP 2.
-.\"O The socket is bound to a local address using
-.\"O .BR bind (2),
-.\"O so that other sockets may be
-.\"O .BR connect (2)ed
-.\"O to it.
-.BR bind (2)
-¤ò»È¤Ã¤Æ¥½¥±¥Ã¥È¤Ë¥í¡¼¥«¥ë¥¢¥É¥ì¥¹¤ò³ä¤êÅö¤Æ¤Æ¡¢
-¾¤Î¥½¥±¥Ã¥È¤¬¤³¤Î¥½¥±¥Ã¥È¤Ë
-.BR connect (2)
-¤Ç¤­¤ë¤è¤¦¤Ë¤¹¤ë¡£
+\fBbind\fP(2)  を使ってソケットにローカルアドレスを割り当てて、 他のソケットがこのソケットに \fBconnect\fP(2)  できるようにする。
 .IP 3.
 .IP 3.
-.\"O A willingness to accept incoming connections and a queue limit for incoming
-.\"O connections are specified with
-.\"O .BR listen ().
-.BR listen ()
-¤ò»È¤Ã¤Æ¡¢ÀܳÍ×µá¤ò¼õ¤±ÉÕ¤±¤ë°Õ»Ö¤ÈÀܳÍ×µá¤òÆþ¤ì¤ë¥­¥å¡¼Ä¹¤ò»ØÄꤹ¤ë¡£
+\fBlisten\fP()  を使って、接続要求を受け付ける意志と接続要求を入れるキュー長を指定する。
 .IP 4.
 .IP 4.
-.\"O Connections are accepted with
-.\"O .BR accept (2).
-.BR accept (2)
-¤ò»È¤Ã¤ÆÀܳ¤ò¼õ¤±ÉÕ¤±¤ë¡£
+\fBaccept\fP(2)  を使って接続を受け付ける。
 .RE
 .PP
 .RE
 .PP
-.\"O POSIX.1-2001 does not require the inclusion of
-.\"O .IR <sys/types.h> ,
-.\"O and this header file is not required on Linux.
-.\"O However, some historical (BSD) implementations required this header
-.\"O file, and portable applications are probably wise to include it.
-POSIX.1-2001 ¤Ç¤Ï
-.I <sys/types.h>
-¤Î¥¤¥ó¥¯¥ë¡¼¥É¤Ïɬ¿Ü¤È¤µ¤ì¤Æ¤ª¤é¤º¡¢
-Linux ¤Ç¤Ï¤³¤Î¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤ÏɬÍפǤϤʤ¤¡£
-¤·¤«¤·¡¢Îò»ËŪ¤Ë¤Ï¡¢¤¤¤¯¤Ä¤«¤Î¼ÂÁõ (BSD ·Ï) ¤Ç¤³¤Î¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤¬
-ɬÍפǤ¢¤ê¡¢°Ü¿¢À­¤¬É¬Íפʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¤³¤Î¥Õ¥¡¥¤¥ë¤ò
-¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¤Î¤¬¸­ÌÀ¤Ç¤¢¤í¤¦¡£
+POSIX.1\-2001 では \fI<sys/types.h>\fP のインクルードは必須とされておらず、 Linux
+ではこのヘッダファイルは必要ではない。 しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダファイルが
+必要であり、移植性が必要なアプリケーションではこのファイルを インクルードするのが賢明であろう。
 
 
-.\"O The behavior of the
-.\"O .I backlog
-.\"O argument on TCP sockets changed with Linux 2.2.
-TCP ¥½¥±¥Ã¥È¤Ç¤Î
-.I backlog
-°ú¤­¿ô¤Î¿¶¤ëÉñ¤¤¤Ï Linux 2.2 ¤ÇÊѹ¹¤µ¤ì¤¿¡£
-.\"O Now it specifies the queue length for
-.\"O .I completely
-.\"O established sockets waiting to be accepted,
-.\"O instead of the number of incomplete connection requests.
-.\"O The maximum length of the queue for incomplete sockets
-.\"O can be set using
-.\"O .IR /proc/sys/net/ipv4/tcp_max_syn_backlog .
-¸½ºß¤Ç¤Ï¤³¤Î°ú¤­¿ô¤Ï¡¢
-¼õ¤±ÉÕ¤±¤é¤ì¤ë¤Î¤òÂԤäƤ¤¤ë¡¢
-.I ´°Á´¤Ë
-³ÎΩ¤µ¤ì¤¿¥½¥±¥Ã¥È¤Î¥­¥å¡¼¤ÎŤµ¤ò»ØÄꤹ¤ë¡£
-°ÊÁ°¤ÏÉÔ´°Á´¤ÊÀܳÍ×µá¤Î¿ô¤Ç¤¢¤Ã¤¿¤¬¡¢¤³¤ì¤òÃÖ¤­´¹¤¨¤¿¡£
-ÉÔ´°Á´¤Ê¥½¥±¥Ã¥È¤Î¥­¥å¡¼¤ÎºÇÂçŤÏ
-.I /proc/sys/net/ipv4/tcp_max_syn_backlog
-¤òÍѤ¤¤ÆÀßÄê¤Ç¤­¤ë¡£
-.\"O When syncookies are enabled there is no logical maximum
-.\"O  length and this setting is ignored.
-.\"O See
-.\"O .BR tcp (7)
-.\"O for more information.
-syncookie ¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¾ì¹ç¡¢
-ÏÀÍýŪ¤ÊºÇÂçĹ¤Ï¸ºß¤»¤º¡¢¤³¤ÎÀßÄê¤Ï̵»ë¤µ¤ì¤ë¡£
+TCP ソケットでの \fIbacklog\fP 引き数の振る舞いは Linux 2.2 で変更された。 現在ではこの引き数は、
+受け付けられるのを待っている、 \fI完全に\fP 確立されたソケットのキューの長さを指定する。 以前は不完全な接続要求の数であったが、これを置き換えた。
+不完全なソケットのキューの最大長は \fI/proc/sys/net/ipv4/tcp_max_syn_backlog\fP を用いて設定できる。
+syncookie が有効になっている場合、 論理的な最大長は存在せず、この設定は無視される。
 
 
-.\"O If the
-.\"O .I backlog
-.\"O argument is greater than the value in
-.\"O .IR /proc/sys/net/core/somaxconn ,
-.\"O then it is silently truncated to that value;
-.\"O the default value in this file is 128.
-.\"O In kernels before 2.4.25, this limit was a hard coded value,
-.\"O .BR SOMAXCONN ,
-.\"O with the value 128.
-.I backlog
-°ú¤­¿ô¤¬
-.I /proc/sys/net/core/somaxconn
-¤ÎÃͤè¤ê¤âÂ礭¤±¤ì¤Ð¡¢
-.I backlog
-¤ÎÃͤϰÅÌۤΤ¦¤Á¤Ë¤³¤ÎÃͤËÀÚ¤êµÍ¤á¤é¤ì¤ë¡£
-¤³¤Î¥Õ¥¡¥¤¥ë¤Î¥Ç¥Õ¥©¥ë¥ÈÃͤϠ128 ¤Ç¤¢¤ë¡£
-¥Ð¡¼¥¸¥ç¥ó 2.4.5 °ÊÁ°¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢¤³¤Î¾å¸ÂÃͤÏ
-¥³¡¼¥ÉËä¤á¹þ¤ß¤Î¸ÇÄêÃÍ
-.B SOMAXCONN
-¤Ç¤¢¤ê¡¢¤½¤ÎÃͤϠ128 ¤Ç¤¢¤Ã¤¿¡£
-.\"O .\" The following is now rather historic information (MTK, Jun 05)
-.\"O .\" Don't rely on this value in portable applications since BSD
-.\"O .\" (and some BSD-derived systems) limit the backlog to 5.
-.\" °Ê²¼¤Ï¡¢º£¤Ç¤Ï¸Å¤¤¾ðÊó¤Ç¤¢¤ë¡£(MTK, Jun 05)
-.\" BSD (¤È¡¢¤¤¤¯¤Ä¤«¤Î BSD ¤«¤éÇÉÀ¸¤·¤¿¥·¥¹¥Æ¥à)¤Ç¤Ï backlog ¤ò 5 ¤Ë
-.\" À©¸Â¤·¤Æ¤¤¤ë¤Î¤Ç¡¢°Ü¿¢À­¤ò¹Íθ¤·¤¿¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï
-.\" ¤³¤ÎÃÍ (SOMAXCONN) ¤ËÍê¤Ã¤Æ¤Ï¤¤¤±¤Ê¤¤¡£
-.\"O .SH EXAMPLE
-.SH Îã
-.\"O See
-.\"O .BR bind (2).
-.BR bind (2)
-»²¾È¡£
-.\"O .SH "SEE ALSO"
-.SH ´ØÏ¢¹àÌÜ
-.BR accept (2),
-.BR bind (2),
-.BR connect (2),
-.BR socket (2),
-.BR socket (7)
+.\" The following is now rather historic information (MTK, Jun 05)
+.\" Don't rely on this value in portable applications since BSD
+.\" (and some BSD-derived systems) limit the backlog to 5.
+\fIbacklog\fP 引き数が \fI/proc/sys/net/core/somaxconn\fP の値よりも大きければ、 \fIbacklog\fP
+の値は暗黙のうちにこの値に切り詰められる。 このファイルのデフォルト値は 128 である。 バージョン 2.4.5 以前のカーネルでは、この上限値は
+コード埋め込みの固定値 \fBSOMAXCONN\fP であり、その値は 128 であった。
+.SH 例
+\fBbind\fP(2)  参照。
+.SH 関連項目
+\fBaccept\fP(2), \fBbind\fP(2), \fBconnect\fP(2), \fBsocket\fP(2), \fBsocket\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.67 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。