OSDN Git Service

LDP: Update draft based on the previous commit (socket)
authorAkihiro Motoki <amotoki@gmail.com>
Mon, 29 Mar 2021 14:13:42 +0000 (23:13 +0900)
committerAkihiro Motoki <amotoki@gmail.com>
Mon, 29 Mar 2021 14:15:48 +0000 (23:15 +0900)
19 files changed:
manual/LDP_man-pages/draft/man2/accept.2
manual/LDP_man-pages/draft/man2/bind.2
manual/LDP_man-pages/draft/man2/connect.2 [new file with mode: 0644]
manual/LDP_man-pages/draft/man2/getsockname.2
manual/LDP_man-pages/draft/man2/getsockopt.2
manual/LDP_man-pages/draft/man2/listen.2
manual/LDP_man-pages/draft/man2/recv.2 [new file with mode: 0644]
manual/LDP_man-pages/draft/man2/recvmmsg.2
manual/LDP_man-pages/draft/man2/select_tut.2 [new file with mode: 0644]
manual/LDP_man-pages/draft/man2/send.2
manual/LDP_man-pages/draft/man2/sendmmsg.2
manual/LDP_man-pages/draft/man2/socket.2 [new file with mode: 0644]
manual/LDP_man-pages/draft/man2/socketcall.2 [new file with mode: 0644]
manual/LDP_man-pages/draft/man2/socketpair.2 [new file with mode: 0644]
manual/LDP_man-pages/draft/man3/getifaddrs.3
manual/LDP_man-pages/draft/man3/if_nameindex.3
manual/LDP_man-pages/draft/man3/if_nametoindex.3
manual/LDP_man-pages/draft/man3/sockatmark.3
manual/LDP_man-pages/draft/man7/socket.7 [new file with mode: 0644]

index a2b305c..1403ddc 100644 (file)
@@ -129,13 +129,12 @@ Linux の \fBaccept\fP()  (と \fBaccept4\fP())  は、新しいソケットに
 .TP 
 \fBEAGAIN\fP または \fBEWOULDBLOCK\fP
 .\" Actually EAGAIN on Linux
-The socket is marked nonblocking and no connections are present to be
-accepted.  POSIX.1\-2001 and POSIX.1\-2008 allow either error to be returned
-for this case, and do not require these constants to have the same value, so
-a portable application should check for both possibilities.
+ソケットが非停止になっていて、 かつ受付け対象の接続が存在しない。 POSIX.1\-2001 と POSIX.1\-2008
+は、この場合にどちらのエラーを返すことも認めており、 これら 2 つの定数が同じ値を持つことも求めていない。
+したがって、移植性が必要なアプリケーションでは、両方の可能性を 確認すべきである。
 .TP 
 \fBEBADF\fP
-\fIsockfd\fP is not an open file descriptor.
+\fIsockfd\fP がオープンされたファイルディスクリプターでない。
 .TP 
 \fBECONNABORTED\fP
 接続が中止された。
@@ -153,17 +152,16 @@ a portable application should check for both possibilities.
 (\fBaccept4\fP())  \fIflags\fP に不正な値が指定されている。
 .TP 
 \fBEMFILE\fP
-The per\-process limit on the number of open file descriptors has been
-reached.
+1プロセスがオープンできるファイルディスクリプター数の上限に達した。
 .TP 
 \fBENFILE\fP
-The system\-wide limit on the total number of open files has been reached.
+オープンされたファイルの総数がシステム全体の上限に達していた。
 .TP 
 \fBENOBUFS\fP, \fBENOMEM\fP
 メモリーが足りない。 多くの場合は、システムメモリーが足りないわけではなく、 ソケットバッファーの大きさによるメモリー割り当ての制限である。
 .TP 
 \fBENOTSOCK\fP
-The file descriptor \fIsockfd\fP does not refer to a socket.
+ファイルディスクリプター \fIsockfd\fP がソケットを参照していない。
 .TP 
 \fBEOPNOTSUPP\fP
 参照しているソケットの型が \fBSOCK_STREAM\fP でない。
@@ -189,8 +187,8 @@ The file descriptor \fIsockfd\fP does not refer to a socket.
 .\" EAGAIN, EBADF, ECONNABORTED, EINTR, EINVAL, EMFILE,
 .\" ENFILE, ENOBUFS, ENOMEM, ENOTSOCK, EOPNOTSUPP, EPROTO, EWOULDBLOCK.
 .\" In addition, SUSv2 documents EFAULT and ENOSR.
-\fBaccept\fP(): POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.4BSD (\fBaccept\fP()  first
-appeared in 4.2BSD).
+\fBaccept\fP(): POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.4BSD, (\fBaccept\fP()  は
+4.2BSD で初めて実装された).
 .PP
 \fBaccept4\fP()  は非標準の Linux による拡張である。
 .PP
@@ -205,21 +203,17 @@ POSIX.1\-2001 では \fI<sys/types.h>\fP のインクルードは必須とされ
 ではこのヘッダーファイルは必要ではない。 しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダーファイルが
 必要であり、移植性が必要なアプリケーションではこのファイルを インクルードするのが賢明であろう。
 .PP
-There may not always be a connection waiting after a \fBSIGIO\fP is delivered
-or \fBselect\fP(2), \fBpoll\fP(2), or \fBepoll\fP(7)  return a readability event
-because the connection might have been removed by an asynchronous network
-error or another thread before \fBaccept\fP()  is called.  If this happens,
-then the call will block waiting for the next connection to arrive.  To
-ensure that \fBaccept\fP()  never blocks, the passed socket \fIsockfd\fP needs to
-have the \fBO_NONBLOCK\fP flag set (see \fBsocket\fP(7)).
+\fBSIGIO\fP が届けられた後や、 \fBselect\fP(2), \fBpoll\fP(2), \fBepoll\fP(7) が読み込み可能イベントを返した後に、
+必ずしも待機中の接続があるとは限らない。 なぜならその接続は、 \fBaccept\fP()  が呼ばれる前に、非同期的なネットワークエラーや
+他のスレッドから呼ばれた (別の) accept によって 削除されているかもしれないからである。 この場合、その \fBaccept\fP()
+呼び出しは停止 (block) し、次の接続の到着を待ちつづける。 \fBaccept\fP()  に停止を行わせないようにするには、引き数に渡すソケット
+\fIsockfd\fP に \fBO_NONBLOCK\fP フラグをセットしておく必要がある (\fBsocket\fP(7)  を見よ)。
 .PP
 .\"
-For certain protocols which require an explicit confirmation, such as
-DECnet, \fBaccept\fP()  can be thought of as merely dequeuing the next
-connection request and not implying confirmation.  Confirmation can be
-implied by a normal read or write on the new file descriptor, and rejection
-can be implied by closing the new socket.  Currently, only DECnet has these
-semantics on Linux.
+明示的な接続確認 (confirmation) を必要とするようなプロトコル (DECnet など) では、 \fBaccept\fP()
+は単に次の接続要求をキューから取り出すだけであり、 接続確認は行わないことに注意せよ。接続確認は、 新しいファイルディスクリプターに対する
+通常の読み取り/書き込みによってなされ、接続拒否 (rejection)  は新しいソケットをクローズすることによってなされる。 現在のところ、
+Linux 上でこれらのセマンティクスを持つのは DECnet だけである。
 .SS "socklen_t 型"
 .\" such as Linux libc4 and libc5, SunOS 4, SGI
 .\" SunOS 5 has 'size_t *'
@@ -227,7 +221,7 @@ In the original BSD sockets implementation (and on other older systems)  the
 third argument of \fBaccept\fP()  was declared as an \fIint\ *\fP.  A POSIX.1g
 draft standard wanted to change it into a \fIsize_t\ *\fPC; later POSIX
 standards and glibc 2.x have \fIsocklen_t\ * \fP.
-.SH EXAMPLES
+.SH 
 \fBbind\fP(2)  参照。
 .SH 関連項目
 \fBbind\fP(2), \fBconnect\fP(2), \fBlisten\fP(2), \fBselect\fP(2), \fBsocket\fP(2),
index aee580b..bb437fa 100644 (file)
@@ -103,11 +103,10 @@ bind \- ソケットに名前をつける
 \fBSOCK_STREAM\fP ソケットが接続を受け付けられるようにするには (\fBaccept\fP(2)  を参照)、通常その前に \fBbind\fP()
 を使用してローカルアドレスを割り当てる必要がある。
 .PP
-The rules used in name binding vary between address families.  Consult the
-manual entries in Section 7 for detailed information.  For \fBAF_INET\fP, see
-\fBip\fP(7); for \fBAF_INET6\fP, see \fBipv6\fP(7); for \fBAF_UNIX\fP, see \fBunix\fP(7);
-for \fBAF_APPLETALK\fP, see \fBddp\fP(7); for \fBAF_PACKET\fP, see \fBpacket\fP(7); for
-\fBAF_X25\fP, see \fBx25\fP(7); and for \fBAF_NETLINK\fP, see \fBnetlink\fP(7).
+名前付けのルールはアドレスファミリーごとに異なっている。詳細な情報は 第 7 章の各マニュアルを参照すること。 \fBAF_INET\fP は
+\fBip\fP(7)  を、 \fBAF_INET6\fP は \fBipv6\fP(7)  を、 \fBAF_UNIX\fP は \fBunix\fP(7)  を、
+\fBAF_APPLETALK\fP は \fBddp\fP(7)  を、 \fBAF_PACKET\fP は \fBpacket\fP(7)  を、 \fBAF_X25\fP は
+\fBx25\fP(7)  を、 \fBAF_NETLINK\fP は \fBnetlink\fP(7)  を参照。
 .PP
 \fIaddr\fP 引き数に実際にどのような構造体が渡されるかは、 アドレスファミリーに依存する。 \fIsockaddr\fP
 構造体は以下のような感じで定義されている:
@@ -121,8 +120,8 @@ struct sockaddr {
 .EE
 .in
 .PP
-The only purpose of this structure is to cast the structure pointer passed
-in \fIaddr\fP in order to avoid compiler warnings.  See EXAMPLES below.
+この構造体は、 \fIaddr\fP に渡される構造体へのポインターをキャストし、 コンパイラの警告メッセージを抑えるためだけに存在する。
+下記の「例」を参照。
 .SH 返り値
 成功した場合にはゼロが返される。エラー時には \-1 が返され、 \fIerrno\fP が適切に設定される。
 .SH エラー
@@ -151,7 +150,7 @@ in \fIaddr\fP in order to avoid compiler warnings.  See EXAMPLES below.
 \fIaddrlen\fP が間違っているか、 \fIaddr\fP がこのソケットのドメインで有効なアドレスではない。
 .TP 
 \fBENOTSOCK\fP
-The file descriptor \fIsockfd\fP does not refer to a socket.
+ファイルディスクリプター \fIsockfd\fP がソケットを参照していない。
 .PP
 以下のエラーは UNIXドメイン (\fBAF_UNIX\fP)  のソケット特有である:
 .TP 
@@ -190,19 +189,18 @@ A component in the directory prefix of the socket pathname does not exist.
 .\" and
 .\" .B EISDIR
 .\" UNIX-domain error conditions.
-POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.4BSD (\fBbind\fP()  first appeared in
-4.2BSD).
+\fBaccept\fP(): POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.4BSD, (\fBbind\fP() は 4.2BSD
+で初めて実装された).
 .SH 注意
-POSIX.1 does not require the inclusion of \fI<sys/types.h>\fP, and this
-header file is not required on Linux.  However, some historical (BSD)
-implementations required this header file, and portable applications are
-probably wise to include it.
+POSIX.1 では \fI<sys/types.h>\fP のインクルードは必須とされておらず、 Linux
+ではこのヘッダーファイルは必要ではない。 しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダーファイルが
+必要であり、移植性が必要なアプリケーションではこのファイルを インクルードするのが賢明であろう。
 .PP
 For background on the \fIsocklen_t\fP type, see \fBaccept\fP(2).
 .SH バグ
 .\" FIXME Document transparent proxy options
 透過的プロキシ (transparent proxy) オプションについて記述していない。
-.SH EXAMPLES
+.SH 
 インターネットドメインソケットでの \fBbind\fP()  の利用例が \fBgetaddrinfo\fP(3)  に記載されている。
 .PP
 .\" listen.7 refers to this example.
diff --git a/manual/LDP_man-pages/draft/man2/connect.2 b/manual/LDP_man-pages/draft/man2/connect.2
new file mode 100644 (file)
index 0000000..081920e
--- /dev/null
@@ -0,0 +1,222 @@
+.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
+.\" Portions extracted from /usr/include/sys/socket.h, which does not have
+.\" any authorship information in it.  It is probably available under the GPL.
+.\"
+.\" %%%LICENSE_START(VERBATIM)
+.\" Permission is granted to make and distribute verbatim copies of this
+.\" manual provided the copyright notice and this permission notice are
+.\" preserved on all copies.
+.\"
+.\" Permission is granted to copy and distribute modified versions of this
+.\" manual under the conditions for verbatim copying, provided that the
+.\" entire resulting derived work is distributed under the terms of a
+.\" permission notice identical to this one.
+.\"
+.\" Since the Linux kernel and libraries are constantly changing, this
+.\" manual page may be incorrect or out-of-date.  The author(s) assume no
+.\" responsibility for errors or omissions, or for damages resulting from
+.\" the use of the information contained herein.  The author(s) may not
+.\" have taken the same level of care in the production of this manual,
+.\" which is licensed free of charge, as they might when working
+.\" professionally.
+.\"
+.\" Formatted or processed versions of this manual, if unaccompanied by
+.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
+.\"
+.\"
+.\" Other portions are from the 6.9 (Berkeley) 3/10/91 man page:
+.\"
+.\" Copyright (c) 1983 The Regents of the University of California.
+.\" 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:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"     This product includes software developed by the University of
+.\"     California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" 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
+.\"
+.\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
+.\" Modified 1998, 1999 by Andi Kleen
+.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
+.\" Japanese Version Copyright (c) 1996 Yosiaki Yanagihara
+.\"         all rights reserved.
+.\" Translated 1996-06-25, Yosiaki Yanagihara <yosiaki@bsd2.kbnes.nec.co.jp>
+.\" Updated & Modified 1997-11-06, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
+.\" Updated & Modified 1999-08-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
+.\" Updated & Modified 2000-01-13, Kentaro Shirakata <argrath@yo.rim.or.jp>
+.\" Updated & Modified 2005-02-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
+.\" Updated & Modified 2005-10-05, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
+.\"
+.TH CONNECT 2 2020\-04\-11 Linux "Linux Programmer's Manual"
+.SH 名前
+connect \- ソケットの接続を行う
+.SH 書式
+.nf
+\fB#include <sys/types.h>\fP          /* 「注意」参照 */
+\fB#include <sys/socket.h>\fP
+.PP
+\fBint connect(int \fP\fIsockfd\fP\fB, const struct sockaddr *\fP\fIaddr\fP\fB,\fP
+\fB            socklen_t \fP\fIaddrlen\fP\fB);\fP
+.fi
+.SH 説明
+\fBconnect\fP()  システムコールは、ファイルディスクリプター \fIsockfd\fP が参照しているソケットを \fIaddr\fP
+で指定されたアドレスに接続する。 \fIaddrlen\fP 引き数は \fIaddr\fP の大きさを示す。 \fIaddr\fP のアドレスのフォーマットはソケット
+\fIsockfd\fP のアドレス空間により異なる。 さらなる詳細は \fBsocket\fP(2)  を参照のこと。
+.PP
+ソケット \fIsockfd\fP が \fBSOCK_DGRAM\fP 型であれば、 \fIaddr\fP は、デフォルトのデータグラムの送信先のアドレスであり、
+データグラムを受信する唯一のアドレスを示すに過ぎない。 ソケットが \fBSOCK_STREAM\fP 型もしくは \fBSOCK_SEQPACKET\fP
+型であれば、このシステムコールは \fIaddr\fP で指定されたアドレスに結び付けられたソケットに対する接続の 作成を試みる。
+.PP
+Some protocol sockets (e.g., UNIX domain stream sockets)  may successfully
+\fBconnect\fP()  only once.
+.PP
+Some protocol sockets (e.g., datagram sockets in the UNIX and Internet
+domains)  may use \fBconnect\fP()  multiple times to change their association.
+.PP
+Some protocol sockets (e.g., TCP sockets as well as datagram sockets in the
+UNIX and Internet domains)  may dissolve the association by connecting to an
+address with the \fIsa_family\fP member of \fIsockaddr\fP set to \fBAF_UNSPEC\fP;
+thereafter, the socket can be connected to another address.  (\fBAF_UNSPEC\fP
+is supported on Linux since kernel 2.2.)
+.SH 返り値
+接続または対応づけに成功するとゼロを返す。 失敗すると \-1 を返し、 \fIerrno\fP に適切な値を設定する。
+.SH エラー
+以下は一般的なソケットについてのエラーである。他にドメイン特有のエラー が発生する可能性がある。
+.TP 
+\fBEACCES\fP
+UNIX ドメインソケットはパス名で識別される。 ソケットファイルへの書き込み許可がなかったか、パス名へ
+到達するまでのディレクトリのいずれかに対する検索許可がなかった。 (\fBpath_resolution\fP(7)  も参照のこと)
+.TP 
+\fBEACCES\fP, \fBEPERM\fP
+ソケットのブロードキャストフラグが有効になっていないのに ユーザーがブロードキャストへ接続を試みた。または、ローカルのファイアウォールの
+規則により接続の要求が失敗した。
+.IP
+\fBEACCES\fP can also be returned if an SELinux policy denied a connection (for
+example, if there is a policy saying that an HTTP proxy can only connect to
+ports associated with HTTP servers, and the proxy tries to connect to a
+different port).  dd
+.TP 
+\fBEADDRINUSE\fP
+ローカルアドレスが既に使用されている。
+.TP 
+\fBEADDRNOTAVAIL\fP
+(インターネットドメインソケットの場合) \fIsockfd\fP が参照するソケットがそれ以前にアドレスにバインドされておらず、
+そのソケットに一時ポートをバインドしようとした際に、 一時ポートとして使用する範囲のポート番号がすべて使用中であった。 \fBip\fP(7) の
+\fI/proc/sys/net/ipv4/ip_local_port_range\fP の議論を参照のこと。
+.TP 
+\fBEAFNOSUPPORT\fP
+渡されたアドレスの \fIsa_family\fP フィールドが正しいアドレスファミリーではない。
+.TP 
+\fBEAGAIN\fP
+For nonblocking UNIX domain sockets, the socket is nonblocking, and the
+connection cannot be completed immediately.  For other socket families,
+there are insufficient entries in the routing cache.
+.TP 
+\fBEALREADY\fP
+ソケットが非停止 (nonblocking) に設定されており、 前の接続が完了していない。
+.TP 
+\fBEBADF\fP
+\fIsockfd\fP が有効なオープンされたファイルディスクリプターでない。
+.TP 
+\fBECONNREFUSED\fP
+A \fBconnect\fP()  on a stream socket found no one listening on the remote
+address.
+.TP 
+\fBEFAULT\fP
+ソケット構造体のアドレスがユーザーのアドレス空間外にある。
+.TP 
+\fBEINPROGRESS\fP
+The socket is nonblocking and the connection cannot be completed
+immediately.  (UNIX domain sockets failed with \fBEAGAIN\fP instead.)  It is
+possible to \fBselect\fP(2)  or \fBpoll\fP(2)  for completion by selecting the
+socket for writing.  After \fBselect\fP(2)  indicates writability, use
+\fBgetsockopt\fP(2)  to read the \fBSO_ERROR\fP option at level \fBSOL_SOCKET\fP to
+determine whether \fBconnect\fP()  completed successfully (\fBSO_ERROR\fP is zero)
+or unsuccessfully (\fBSO_ERROR\fP is one of the usual error codes listed here,
+explaining the reason for the failure).
+.TP 
+\fBEINTR\fP
+.\" For TCP, the connection will complete asynchronously.
+.\" See http://lkml.org/lkml/2005/7/12/254
+捕捉されたシグナルによりシステムコールが中断された。 \fBsignal\fP(7)  参照。
+.TP 
+\fBEISCONN\fP
+ソケットは既に接続 (connect) されている。
+.TP 
+\fBENETUNREACH\fP
+到達できないネットワークである。
+.TP 
+\fBENOTSOCK\fP
+ファイルディスクリプター \fIsockfd\fP がソケットを参照していない。
+.TP 
+\fBEPROTOTYPE\fP
+ソケットタイプが要求された通信プロトコルではサポートされていない。 このエラーは、 例えば UNIX
+ドメインデータグラムソケットをストリームソケットに接続しようとした場合などに起こり得る。
+.TP 
+\fBETIMEDOUT\fP
+接続を試みている途中で時間切れ (timeout) になった。サーバーが混雑していて 新たな接続を受け入れられないのかもしれない。 IP ソケットでは、
+syncookie がサーバーで有効になっている場合、 タイムアウトが非常に長くなる場合があるので注意すること。
+.SH 準拠
+.\" SVr4 documents the additional
+.\" general error codes
+.\" .BR EADDRNOTAVAIL ,
+.\" .BR EINVAL ,
+.\" .BR EAFNOSUPPORT ,
+.\" .BR EALREADY ,
+.\" .BR EINTR ,
+.\" .BR EPROTOTYPE ,
+.\" and
+.\" .BR ENOSR .
+.\" It also
+.\" documents many additional error conditions not described here.
+\fBaccept\fP(): POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.4BSD, (\fBconnect\fP()  は
+4.2BSD で初めて実装された).
+.SH 注意
+POSIX.1 では \fI<sys/types.h>\fP のインクルードは必須とされておらず、 Linux
+ではこのヘッダーファイルは必要ではない。 しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダーファイルが
+必要であり、移植性が必要なアプリケーションではこのファイルを インクルードするのが賢明であろう。
+.PP
+For background on the \fIsocklen_t\fP type, see \fBaccept\fP(2).
+.PP
+\fBconnect\fP() が失敗した場合、そのソケットの状態は不定だと考えること。
+移植性を考慮したアプリケーションでは、そのソケットをクローズし、再接続用に新しいソケットを作成すべきである。
+.SH 例
+\fBconnect\fP()  の利用例が \fBgetaddrinfo\fP(3)  に記載されている。
+.SH 関連項目
+\fBaccept\fP(2), \fBbind\fP(2), \fBgetsockname\fP(2), \fBlisten\fP(2), \fBsocket\fP(2),
+\fBpath_resolution\fP(7), \fBselinux\fP(8)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
+\%https://www.kernel.org/doc/man\-pages/ に書かれている。
index f3c39ec..cf33d36 100644 (file)
@@ -73,7 +73,7 @@ getsockname \- ソケットの名前を取得する
 .SH エラー
 .TP 
 \fBEBADF\fP
-The argument \fIsockfd\fP is not a valid file descriptor.
+引き数 \fIsockfd\fP は有効なファイルディスクリプターでない。
 .TP 
 \fBEFAULT\fP
 引き数 \fIaddr\fP の指しているメモリーがプロセスのアドレス空間の有効な部分ではない。
@@ -85,12 +85,12 @@ The argument \fIsockfd\fP is not a valid file descriptor.
 処理をするだけの十分なリソースがシステムに無い。
 .TP 
 \fBENOTSOCK\fP
-The file descriptor \fIsockfd\fP does not refer to a socket.
+ファイルディスクリプター \fIsockfd\fP がソケットを参照していない。
 .SH 準拠
 .\" SVr4 documents additional ENOMEM
 .\" and ENOSR error codes.
-POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.4BSD (\fBgetsockname\fP()  first appeared
-in 4.2BSD).
+POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.4BSD (\fBgetsockname\fP() は 4.2BSD
+で初めて実装された)
 .SH 注意
 For background on the \fIsocklen_t\fP type, see \fBaccept\fP(2).
 .SH 関連項目
index 18f22d0..9510666 100644 (file)
@@ -102,7 +102,7 @@ value returned by the handler.
 .SH エラー
 .TP 
 \fBEBADF\fP
-The argument \fIsockfd\fP is not a valid file descriptor.
+引き数 \fIsockfd\fP は有効なファイルディスクリプターでない。
 .TP 
 \fBEFAULT\fP
 \fIoptval\fP で指定されたアドレスがプロセスのアドレス空間の有効な部分ではない。 \fBgetsockopt\fP()  の場合、 \fIoptlen\fP
@@ -117,19 +117,17 @@ The argument \fIsockfd\fP is not a valid file descriptor.
 指定された層(level)にはこのオプションは存在しない。
 .TP 
 \fBENOTSOCK\fP
-The file descriptor \fIsockfd\fP does not refer to a socket.
+ファイルディスクリプター \fIsockfd\fP がソケットを参照していない。
 .SH 準拠
 .\" SVr4 documents additional ENOMEM and ENOSR error codes, but does
 .\" not document the
 .\" .BR SO_SNDLOWAT ", " SO_RCVLOWAT ", " SO_SNDTIMEO ", " SO_RCVTIMEO
 .\" options
-POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.4BSD (these system calls first appeared
-in 4.2BSD).
+POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.4BSD (これらのシステムコールは 4.2BSD で最初に現れた)
 .SH 注意
-POSIX.1 does not require the inclusion of \fI<sys/types.h>\fP, and this
-header file is not required on Linux.  However, some historical (BSD)
-implementations required this header file, and portable applications are
-probably wise to include it.
+POSIX.1 では \fI<sys/types.h>\fP のインクルードは必須とされておらず、 Linux
+ではこのヘッダーファイルは必要ではない。 しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダーファイルが
+必要であり、移植性が必要なアプリケーションではこのファイルを インクルードするのが賢明であろう。
 .PP
 For background on the \fIsocklen_t\fP type, see \fBaccept\fP(2).
 .SH バグ
index 62bdf67..2e9e32b 100644 (file)
@@ -90,15 +90,15 @@ listen \- ソケット(socket)上の接続を待つ
 \fI/proc/sys/net/ipv4/ip_local_port_range\fP の議論を参照のこと。
 .TP 
 \fBEBADF\fP
-The argument \fIsockfd\fP is not a valid file descriptor.
+引き数 \fIsockfd\fP は有効なファイルディスクリプターでない。
 .TP 
 \fBENOTSOCK\fP
-The file descriptor \fIsockfd\fP does not refer to a socket.
+ファイルディスクリプター \fIsockfd\fP がソケットを参照していない。
 .TP 
 \fBEOPNOTSUPP\fP
 ソケットは \fBlisten\fP()  がサポートしている型ではない。
 .SH 準拠
-POSIX.1\-2001, POSIX.1\-2008, 4.4BSD (\fBlisten\fP()  first appeared in 4.2BSD).
+POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.4BSD (\fBlisten\fP()  は 4.2BSD で初めて実装された)
 .SH 注意
 接続を受け付けるには、以下の処理が実行される。
 .RS 4
@@ -112,10 +112,9 @@ POSIX.1\-2001, POSIX.1\-2008, 4.4BSD (\fBlisten\fP()  first appeared in 4.2BSD).
 \fBaccept\fP(2)  を使って接続を受け付ける。
 .RE
 .PP
-POSIX.1 does not require the inclusion of \fI<sys/types.h>\fP, and this
-header file is not required on Linux.  However, some historical (BSD)
-implementations required this header file, and portable applications are
-probably wise to include it.
+POSIX.1 では \fI<sys/types.h>\fP のインクルードは必須とされておらず、 Linux
+ではこのヘッダーファイルは必要ではない。 しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダーファイルが
+必要であり、移植性が必要なアプリケーションではこのファイルを インクルードするのが賢明であろう。
 .PP
 TCP ソケットでの \fIbacklog\fP 引き数の振る舞いは Linux 2.2 で変更された。 現在ではこの引き数は、
 受け付けられるのを待っている、 \fI完全に\fP 確立されたソケットのキューの長さを指定する。 以前は不完全な接続要求の数であったが、これを置き換えた。
@@ -130,7 +129,7 @@ If the \fIbacklog\fP argument is greater than the value in
 value.  Since Linux 5.4, the default in this file is 4096; in earlier
 kernels, the default value is 128.  In kernels before 2.4.25, this limit was
 a hard coded value, \fBSOMAXCONN\fP, with the value 128.
-.SH EXAMPLES
+.SH 
 \fBbind\fP(2)  参照。
 .SH 関連項目
 \fBaccept\fP(2), \fBbind\fP(2), \fBconnect\fP(2), \fBsocket\fP(2), \fBsocket\fP(7)
diff --git a/manual/LDP_man-pages/draft/man2/recv.2 b/manual/LDP_man-pages/draft/man2/recv.2
new file mode 100644 (file)
index 0000000..dbcaf75
--- /dev/null
@@ -0,0 +1,368 @@
+.\" Copyright (c) 1983, 1990, 1991 The Regents of the University of California.
+.\" 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:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by the University of
+.\"    California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" 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: recv.2,v 1.3 1999/05/13 11:33:38 freitag Exp $
+.\"
+.\" Modified Sat Jul 24 00:22:20 1993 by Rik Faith <faith@cs.unc.edu>
+.\" Modified Tue Oct 22 17:45:19 1996 by Eric S. Raymond <esr@thyrsus.com>
+.\" Modified 1998,1999 by Andi Kleen
+.\" 2001-06-19 corrected SO_EE_OFFENDER, bug report by James Hawtin
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
+.\" Japanese Version Copyright (c) 1996 Akira Yoshiyama
+.\"         all rights reserved.
+.\" Translated 1996-07-18, Akira Yoshiyama <yosshy@jedi.seg.kobe-u.ac.jp>
+.\" Modified 1997-12-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
+.\" Modified 1999-08-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
+.\" Updated & Modified 2000-10-12, HAYAKAWA Hitoshi <cz8cb01@linux.or.jp>
+.\"        and NAKANO Takeo <nakano@apm.seikei.ac.jp>
+.\" Updated & Modified 2001-02-09, NAKANO Takeo
+.\" Updated 2003-10-11, Kentaro Shirakata <argrath@ub32.org>
+.\" Updated 2005-03-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
+.\" Updated 2006-04-15, Akihiro MOTOKI, Catch up to LDP v2.29
+.\" Updated 2007-10-12, Akihiro MOTOKI, LDP v2.66
+.\" Updated 2008-08-06, Akihiro MOTOKI, LDP v3.05
+.\" Updated 2009-04-13, Akihiro MOTOKI, LDP v3.20
+.\" Updated 2013-03-26, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-07-22, Akihiro MOTOKI <amotoki@gmail.com>
+.\"
+.TH RECV 2 2020\-11\-01 Linux "Linux Programmer's Manual"
+.SH 名前
+recv, recvfrom, recvmsg \- ソケットからメッセージを受け取る
+.SH 書式
+.\" .B #include <sys/uio.h>
+.\" .br
+.nf
+\fB#include <sys/types.h>\fP
+\fB#include <sys/socket.h>\fP
+.PP
+\fBssize_t recv(int \fP\fIsockfd\fP\fB, void *\fP\fIbuf\fP\fB, size_t \fP\fIlen\fP\fB, int \fP\fIflags\fP\fB);\fP
+.PP
+\fBssize_t recvfrom(int \fP\fIsockfd\fP\fB, void *\fP\fIbuf\fP\fB, size_t \fP\fIlen\fP\fB, int \fP\fIflags\fP\fB,\fP
+\fB                 struct sockaddr *\fP\fIsrc_addr\fP\fB, socklen_t *\fP\fIaddrlen\fP\fB);\fP
+.PP
+\fBssize_t recvmsg(int \fP\fIsockfd\fP\fB, struct msghdr *\fP\fImsg\fP\fB, int \fP\fIflags\fP\fB);\fP
+.fi
+.SH 説明
+\fBrecv\fP(), \fBrecvfrom\fP(), \fBrecvmsg\fP() コールは、 ソケットからメッセージを受け取るのに使用される。
+これらはコネクションレス型のソケットにも接続指向 (connection\-oriened) 型のソケットにも使用できる。 このページでは、まずこれら 3
+つのシステムコールすべてに共通の機能について説明し、 システムコール間の違いについて説明する。
+.PP
+The only difference between \fBrecv\fP()  and \fBread\fP(2)  is the presence of
+\fIflags\fP.  With a zero \fIflags\fP argument, \fBrecv\fP()  is generally equivalent
+to \fBread\fP(2)  (but see NOTES).  Also, the following call
+.PP
+    recv(sockfd, buf, len, flags);
+.PP
+は以下と等価である。
+.PP
+    recvfrom(sockfd, buf, len, flags, NULL, NULL);
+.PP
+これらの三つのシステムコールはいずれも、成功した場合にはメッセージの長さを返す。 メッセージが長過ぎて指定されたバッファーに入り切らなかった場合には、
+メッセージを受信したソケットの種類によっては余分のバイトが捨てられる かもしれない。
+.PP
+ソケットに受け取るメッセージが存在しなかった場合、 受信用のコールはメッセージが到着するまで待つ。 ただし、ソケットが非停止 (nonblocking)
+に設定されていた場合 (\fBfcntl\fP(2)  を参照) は \-1 を返し、外部変数 \fIerrno\fP に \fBEAGAIN\fP か
+\fBEWOULDBLOCK\fP を設定する。 これらの受信用のコールは、受信したデータのサイズが要求したサイズに
+達するまで待つのではなく、何らかのデータを受信すると復帰する (受信されるデータの最大サイズは要求したサイズである)。
+.PP
+アプリケーションは \fBselect\fP(2), \fBpoll\fP(2), \fBepoll\fP(7)
+を使って、ソケットにさらにデータが到着しているかを判定することができる。
+.SS フラグ引き数
+\fIflags\fP 引き数には、以下の値を 1つ以上、ビット単位の論理和 を取ったものを指定する:
+.TP 
+\fBMSG_CMSG_CLOEXEC\fP (\fBrecvmsg\fP() のみ; Linux 2.6.23)
+(\fBunix\fP(7)  で説明されている)  \fBSCM_RIGHTS\fP 操作を使って UNIX ドメインのファイルディスクリプター経由で受信した
+ファイルディスクリプターについて close\-on\-exec フラグをセットする。 このフラグは、 \fBopen\fP(2)  の \fBO_CLOEXEC\fP
+フラグと同じ理由で有用である。
+.TP 
+\fBMSG_DONTWAIT\fP (Linux 2.2 以降)
+Enables nonblocking operation; if the operation would block, the call fails
+with the error \fBEAGAIN\fP or \fBEWOULDBLOCK\fP.  This provides similar behavior
+to setting the \fBO_NONBLOCK\fP flag (via the \fBfcntl\fP(2)  \fBF_SETFL\fP
+operation), but differs in that \fBMSG_DONTWAIT\fP is a per\-call option,
+whereas \fBO_NONBLOCK\fP is a setting on the open file description (see
+\fBopen\fP(2)), which will affect all threads in the calling process and as
+well as other processes that hold file descriptors referring to the same
+open file description.
+.TP 
+\fBMSG_ERRQUEUE\fP (Linux 2.2 以降)
+このフラグを指定すると、 キューに入れられたエラーをソケットのエラーキューから取りだせるようになる。 このエラーは補助メッセージに組み込まれて渡され、
+この補助メッセージの種別はプロトコルに依存する (IPv4 の場合は \fBIP_RECVERR\fP)。
+ユーザーは十分なサイズのバッファーを用意しなければならない。 補助メッセージに関するより詳細な情報は \fBcmsg\fP(3)  および \fBip\fP(7)
+を参照のこと。 エラーの原因となったオリジナルパケットのペイロードは、 \fImsg_iovec\fP 経由で通常のデータとして渡される。
+エラーを起こしたデータグラムのオリジナルの宛先アドレスは、 \fImsg_name\fP 経由で参照できる。
+.IP
+このエラーは \fIsock_extended_err\fP 構造体で提供される:
+.IP
+.in +4n
+.EX
+#define SO_EE_ORIGIN_NONE    0
+#define SO_EE_ORIGIN_LOCAL   1
+#define SO_EE_ORIGIN_ICMP    2
+#define SO_EE_ORIGIN_ICMP6   3
+
+struct sock_extended_err
+{
+    uint32_t ee_errno;   /* Error number */
+    uint8_t  ee_origin;  /* Where the error originated */
+    uint8_t  ee_type;    /* Type */
+    uint8_t  ee_code;    /* Code */
+    uint8_t  ee_pad;     /* Padding */
+    uint32_t ee_info;    /* Additional information */
+    uint32_t ee_data;    /* Other data */
+    /* More data may follow */
+};
+
+struct sockaddr *SO_EE_OFFENDER(struct sock_extended_err *);
+.EE
+.in
+.IP
+\fIee_errno\fP にはキューに入れられたエラーの \fIerrno\fP が入っている。 \fIee_origin\fP
+にはエラーが発生した場所のオリジンコード (origin code) が入っている。 他のフィールドはプロトコル依存である。
+\fBSO_EE_OFFENDER\fP マクロは、この補助的なメッセージを引き数に取って、
+エラーの発生したネットワークオブジェクトのアドレスへのポインターを返す。 アドレスが不明の場合には、 \fIsockaddr\fP の
+\fIsa_family\fP メンバーが \fBAF_UNSPEC\fP になっている。 \fIsockaddr\fP の他のフィールドは不定である。
+エラーの発生したパケットのペイロードは通常のデータとして渡される。
+.IP
+ローカルなエラーの場合はアドレスは渡されない (これは \fIcmsghdr\fP の \fIcmsg_len\fP メンバーでチェックできる)。受信エラーの場合は
+\fBMSG_ERRQUIE\fP フラグが \fImsghdr\fP
+にセットされる。エラーが渡された後には、キューに入っている次のエラーに基いて、処理待ちのソケットエラーが再生成され、次のソケット操作の際に渡される。
+.TP 
+\fBMSG_OOB\fP
+このフラグは、通常のデータストリームでは受信できない 帯域外 (out\-of\-band) データの受信を要求する。 プロトコルによっては、
+通常のデータキューの先頭に速達データを置くものがあるが、 そのようなプロトコルではこのフラグは使用できない。
+.TP 
+\fBMSG_PEEK\fP
+このフラグを指定すると、 受信キューの最初のデータを返すとき、キューからデータを削除しない。
+したがって、この後でもう一度受信コールを呼び出すと、同じデータが返ることになる。
+.TP 
+\fBMSG_TRUNC\fP (Linux 2.2 以降)
+.\" commit 9f6f9af7694ede6314bed281eec74d588ba9474f
+raw ソケット (\fBAF_PACKET\fP)、 Internet datagram ソケット (Linux 2.4.27/2.6.8 以降)、
+netlink (Linux 2.6.22 以降) ソケット、 UNIX datagram ソケット (Linux 3.4 以降)
+の場合、パケットやデータグラムの長さが渡したバッファーよりも長かった場合にも、 パケットやデータグラムの実際の長さを返す。
+.IP
+Internet ストリームソケットでの利用については \fBtcp\fP(7)  を参照。
+.TP 
+\fBMSG_WAITALL\fP (Linux 2.2 以降)
+.\"
+This flag requests that the operation block until the full request is
+satisfied.  However, the call may still return less data than requested if a
+signal is caught, an error or disconnect occurs, or the next data to be
+received is of a different type than that returned.  This flag has no effect
+for datagram sockets.
+.SS recvfrom()
+\fBrecvfrom\fP() は受信したメッセージをバッファー \fIbuf\fP に格納する。 呼び出し元はバッファーサイズを \fIlen\fP
+で指定しなければならない。
+.PP
+.\" (Note: for datagram sockets in both the UNIX and Internet domains,
+.\" .I src_addr
+.\" is filled in.
+.\" .I src_addr
+.\" is also filled in for stream sockets in the UNIX domain, but is not
+.\" filled in for stream sockets in the Internet domain.)
+.\" [The above notes on AF_UNIX and AF_INET sockets apply as at
+.\" Kernel 2.4.18. (MTK, 22 Jul 02)]
+\fIsrc_addr\fP が NULL 以外で、下層のプロトコルからメッセージの送信元アドレスが分かる場合、 この送信元アドレスが \fIsrc_addr\fP
+が指すバッファーに格納される。 この場合、 \fIaddrlen\fP は入出力両用の引き数となる。 呼び出し前に、呼び出し元は \fIsrc_addr\fP
+に割り当てたバッファーの大きさで初期化しておくべきである。 返ってくる時には、 \fIaddrlen\fP
+は送信元アドレスの実際の大きさに変更される。渡されたバッファーが小さ過ぎる場合には、返されるアドレスの末尾は 切り詰められる。この場合には、
+\fIaddrlen\fP では、呼び出し時に渡された値よりも大きな値が返される。
+.PP
+.\"
+呼び出し元が送信元アドレスを必要としない場合は、 \fIsrc_addr\fP と \fIaddrlen\fP には NULL を指定すべきである。
+.SS recv()
+\fBrecv\fP()  コールは通常 \fI接続済みの (connected)\fP ソケットに対してのみ使用される (\fBconnect\fP(2)
+参照)。次の呼び出しと等価である。
+.PP
+.\"
+    recvfrom(fd, buf, len, flags, NULL, 0);
+.SS recvmsg()
+\fBrecvmsg\fP()  コールは、直接渡す引き数の数を減らすために \fImsghdr\fP 構造体を使用する。この構造体は
+\fI<sys/socket.h>\fP で以下のように定義されている:
+.PP
+.in +4n
+.EX
+struct iovec {                    /* Scatter/gather array items */
+    void  *iov_base;              /* Starting address */
+    size_t iov_len;               /* Number of bytes to transfer */
+};
+
+struct msghdr {
+    void         *msg_name;       /* 追加のアドレス */
+    socklen_t     msg_namelen;    /* アドレスのサイズ */
+    struct iovec *msg_iov;        /* scatter/gather 配列 */
+    size_t        msg_iovlen;     /* msg_iov の要素数 */
+    void         *msg_control;    /* 補助データ (後述) */
+    size_t        msg_controllen; /* 補助データバッファー長 */
+    int           msg_flags;      /* 受信メッセージのフラグ */
+};
+.EE
+.in
+.PP
+フィールド \fImsg_name\fP は、 ソケットが接続されていない場合に送信元アドレスを返すのに使用されるバッファーを指す。
+このバッファーは呼び出し元が確保する。 呼び出し元は呼び出し前に \fImsg_namelen\fP にこのバッファーの大きさを設定しなければならない。
+呼び出しが成功した場合、呼び出しから返って来た際には \fImsg_namelen\fP には返されるアドレスの長さが入っている。
+アプリケーションが送信元アドレスを知る必要がない場合には、 \fImsg_name\fP に NULL を指定することができる。
+.PP
+\fImsg_iov\fP と \fImsg_iovlen\fP フィールドは scatter\-gather 用の場所を指定する。 \fBreadv\fP(2)
+に説明がある。
+.PP
+\fImsg_control\fP フィールドは \fImsg_controllen\fP の長さを持ち、他のプロトコル制御メッセージや
+種々の補助データのためのバッファーへのポインターである。 \fBrecvmsg\fP()  を呼ぶ際には、 \fImsg_controllen\fP に
+\fImsg_control\fP のバッファーの長さを入れておく必要がある。 コールが成功して返った場合、制御メッセージ列の長さが入っている。
+.PP
+メッセージの形式は以下の通り:
+.PP
+.in +4n
+.EX
+struct cmsghdr {
+    size_t cmsg_len;    /* Data byte count, including header
+                           (type is socklen_t in POSIX) */
+    int    cmsg_level;  /* Originating protocol */
+    int    cmsg_type;   /* Protocol\-specific type */
+/* followed by
+    unsigned char cmsg_data[]; */
+};
+.EE
+.in
+.PP
+補助データは、 \fBcmsg\fP(3)  に定義されたマクロ経由でのみアクセスすべきである。
+.PP
+As an example, Linux uses this ancillary data mechanism to pass extended
+errors, IP options, or file descriptors over UNIX domain sockets.  For
+further information on the use of ancillary data in various socket domains,
+see \fBunix\fP(7)  and \fBip\fP(7).
+.PP
+\fImsghdr\fP の \fImsg_flags\fP フィールドは \fBrecvmsg\fP()
+からのリターン時に設定される。ここにはいくつかのフラグが入る。
+.TP 
+\fBMSG_EOR\fP
+これはレコードの終り (end\-of\-record) を示し、 返されたデータが完全なレコードであることを示す (一般的には
+\fBSOCK_SEQPACKET\fP 型のソケットで使用される)。
+.TP 
+\fBMSG_TRUNC\fP
+データグラムが与えられたバッファーより大きかったために、 データグラムのはみ出した部分が捨てられたことを示す。
+.TP 
+\fBMSG_CTRUNC\fP
+補助データのためのバッファーが不足したために、 制御データの一部が捨てられたことを示す。
+.TP 
+\fBMSG_OOB\fP
+速達データや帯域外データを受信したことを示す。
+.TP 
+\fBMSG_ERRQUEUE\fP
+データは受信しなかったが ソケットのエラーキューから拡張エラーを受信したことを示す。
+.SH 返り値
+これらのコールは受信したバイト数を返す。 エラーの場合は \-1 を返し、 \fIerrno\fP にエラーを示す値を設定する。
+.PP
+ストリームソケットの接続相手が正しくシャットダウンを実行した場合は、
+返り値は 0 (昔ながらの "end\-of\-file" の戻り値) となる。
+.PP
+いくつかのドメインのデータグラムソケット (UNIX ドメインやインターネットドメインなど) では、長さ 0 のデータグラムが送信できる。
+このようなデータグラムを受信した場合、 返り値は 0 となる。
+.PP
+ストリームソケットに対する受信要求バイト数が 0 だった場合も、 値 0 が返される。
+.SH エラー
+これらはソケット層で発生する一般的なエラーである。 他のエラーが下層のプロトコルモジュールで生成され、 返されるかもしれない。
+それらのマニュアルを参照すること。
+.TP 
+\fBEAGAIN\fP または \fBEWOULDBLOCK\fP
+.\" Actually EAGAIN on Linux
+ソケットが非停止 (nonblocking) に設定されていて 受信操作が停止するような状況になったか、 受信に時間切れ (timeout)
+が設定されていて データを受信する前に時間切れになった。 POSIX.1 は、この場合にどちらのエラーを返すことも認めており、 これら 2
+つの定数が同じ値を持つことも求めていない。 したがって、移植性が必要なアプリケーションでは、両方の可能性を 確認すべきである。
+.TP 
+\fBEBADF\fP
+引き数 \fIsockfd\fP が不正なファイルディスクリプターである。
+.TP 
+\fBECONNREFUSED\fP
+リモートのホストでネットワーク接続が拒否された (よくある理由としては、要求したサービスが起動されていないなどがある)。
+.TP 
+\fBEFAULT\fP
+受信バッファーへのポインターがプロセスのアドレス空間外を指している。
+.TP 
+\fBEINTR\fP
+データを受信する前に、シグナルが配送されて割り込まれた。 \fBsignal\fP(7)  参照。
+.TP 
+\fBEINVAL\fP
+.\" e.g., msg_namelen < 0 for recvmsg() or addrlen < 0 for recvfrom()
+不正な引き数が渡された。
+.TP 
+\fBENOMEM\fP
+\fBrecvmsg\fP()  のためのメモリーが確保できなかった。
+.TP 
+\fBENOTCONN\fP
+ソケットに接続指向プロトコルが割り当てられており、 まだ接続されていない (\fBconnect\fP(2)  と \fBaccept\fP(2)
+を参照のこと)。
+.TP 
+\fBENOTSOCK\fP
+ファイルディスクリプター \fIsockfd\fP がソケットを参照していない。
+.SH 準拠
+POSIX.1\-2001, POSIX.1\-2008, 4.4BSD (これらのインターフェースは 4.2BSD で初めて実装された)
+.PP
+POSIX.1 では、 \fBMSG_OOB\fP, \fBMSG_PEEK\fP, \fBMSG_WAITALL\fP フラグだけが記載されている。
+.SH 注意
+If a zero\-length datagram is pending, \fBread\fP(2)  and \fBrecv\fP()  with a
+\fIflags\fP argument of zero provide different behavior.  In this circumstance,
+\fBread\fP(2)  has no effect (the datagram remains pending), while \fBrecv\fP()
+consumes the pending datagram.
+.PP
+\fIsocklen_t\fP 型は POSIX で発案された。 \fBaccept\fP(2) も参照。
+.PP
+.\" POSIX.1-2001, POSIX.1-2008
+.\" glibc bug for msg_controllen raised 12 Mar 2006
+.\" http://sourceware.org/bugzilla/show_bug.cgi?id=2448
+.\" The problem is an underlying kernel issue: the size of the
+.\" __kernel_size_t type used to type these fields varies
+.\" across architectures, but socklen_t is always 32 bits,
+.\" as (at least with GCC) is int.
+According to POSIX.1, the \fImsg_controllen\fP field of the \fImsghdr\fP structure
+should be typed as \fIsocklen_t\fP, and the \fImsg_iovlen\fP field should be typed
+as \fIint\fP, but glibc currently types both as \fIsize_t\fP.
+.PP
+\fBrecvmmsg\fP(2)  には、一度の呼び出しでの複数のデータグラムに使用できる Linux 固有の システムコールに関する情報が書かれている。
+.SH 例
+\fBrecvfrom\fP()  の利用例が \fBgetaddrinfo\fP(3)  に記載されている。
+.SH 関連項目
+\fBfcntl\fP(2), \fBgetsockopt\fP(2), \fBread\fP(2), \fBrecvmmsg\fP(2), \fBselect\fP(2),
+\fBshutdown\fP(2), \fBsocket\fP(2), \fBcmsg\fP(3), \fBsockatmark\fP(3), \fBip\fP(7),
+\fBipv6\fP(7), \fBsocket\fP(7), \fBtcp\fP(7), \fBudp\fP(7), \fBunix\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
+\%https://www.kernel.org/doc/man\-pages/ に書かれている。
index f608899..21494c7 100644 (file)
@@ -119,7 +119,7 @@ expected to be returned on a subsequent call to \fBrecvmmsg\fP().  In the
 current implementation, however, the error code can be overwritten in the
 meantime by an unrelated network event on a socket, for example an incoming
 ICMP packet.
-.SH EXAMPLES
+.SH 
 以下のプログラムは、 \fBrecvmmsg\fP() を使って複数のメッセージをソケットから受信し、それらを複数のバッファーに格納する。
 呼び出しは、すべてのバッファーにメッセージが格納されるか、 指定したタイムアウト時間が経過すると返る。
 .PP
diff --git a/manual/LDP_man-pages/draft/man2/select_tut.2 b/manual/LDP_man-pages/draft/man2/select_tut.2
new file mode 100644 (file)
index 0000000..c00cf0f
--- /dev/null
@@ -0,0 +1,504 @@
+.\" This manpage is copyright (C) 2001 Paul Sheer.
+.\"
+.\" %%%LICENSE_START(VERBATIM)
+.\" Permission is granted to make and distribute verbatim copies of this
+.\" manual provided the copyright notice and this permission notice are
+.\" preserved on all copies.
+.\"
+.\" Permission is granted to copy and distribute modified versions of this
+.\" manual under the conditions for verbatim copying, provided that the
+.\" entire resulting derived work is distributed under the terms of a
+.\" permission notice identical to this one.
+.\"
+.\" Since the Linux kernel and libraries are constantly changing, this
+.\" manual page may be incorrect or out-of-date.  The author(s) assume no
+.\" responsibility for errors or omissions, or for damages resulting from
+.\" the use of the information contained herein.  The author(s) may not
+.\" have taken the same level of care in the production of this manual,
+.\" which is licensed free of charge, as they might when working
+.\" professionally.
+.\"
+.\" Formatted or processed versions of this manual, if unaccompanied by
+.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
+.\"
+.\" very minor changes, aeb
+.\"
+.\" Modified 5 June 2002, Michael Kerrisk <mtk.manpages@gmail.com>
+.\" 2006-05-13, mtk, removed much material that is redundant with select.2
+.\"             various other changes
+.\" 2008-01-26, mtk, substantial changes and rewrites
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
+.\" Translated 2002-02-21, NAKANO Takeo <nakano@apm.seikei.ac.jp>
+.\" Updated 2002-09-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
+.\" Updated 2005-03-15, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
+.\" Updated 2006-07-21, Akihiro MOTOKI, LDP v2.36
+.\" Updated 2009-02-13, Akihiro MOTOKI, LDP v3.18
+.\"
+.TH SELECT_TUT 2 2020\-04\-11 Linux "Linux Programmer's Manual"
+.SH 名前
+select, pselect \- 同期 I/O の多重化
+.SH 書式
+\fBselect\fP(2)  参照。
+.SH 説明
+システムコール \fBselect\fP() や \fBpselect\fP() を使うと、効率的に複数のファイルディスクリプターを監視し、
+そのファイルディスクリプターのいずれかが 「ready (準備ができた)」状態、つまり I/O (入出力) が可能になっているかや、
+ファイルディスクリプターのいずれかが 「例外状態 (exceptional condition)」が発生したか、を調べることができる。
+.PP
+.\"
+This page provides background and tutorial information on the use of these
+system calls.  For details of the arguments and semantics of \fBselect\fP()
+and \fBpselect\fP(), see \fBselect\fP(2).
+.SS シグナルとデータイベントを組み合わせる
+ファイルディスクリプターが I/O 可能な状態になるのと同時に シグナルも待ちたい場合には、 \fBpselect\fP()  が便利である。
+シグナルを受信するプログラムは、通常は、 シグナルハンドラーをグローバルなフラグを立てるためだけに使う。 このグローバルなフラグは、
+そのイベントをプログラムのメインループで 処理しなければならないことを示す。 シグナルを受けると \fBselect\fP()  (や
+\fBpselect\fP())  は \fIerrno\fP に \fBEINTR\fP をセットして戻ることになる。
+シグナルがプログラムのメインループで処理されるためにはこの動作が不可欠で、 これがないと \fBselect\fP()  は永遠に停止し続けることになる。
+.PP
+さて、メインループのどこかにこのグローバルフラグをチェックする 条件文があるとしよう。ここで少し考えてみないといけない。 「シグナルが条件文の後、しかし
+\fBselect\fP()  コールの前に到着したら どうなるのか?」 答えは「その \fBselect\fP()
+は、たとえ解決待ちのイベントがあったとしても、 永遠に停止する」である。 この競合状態は \fBpselect\fP()  コールによって解決できる。
+このコールを使うと、 \fBpselect\fP() でのみ受信したいシグナルの集合をシグナルマスクに設定することができる。
+例えば、問題となっているイベントが子プロセスの終了の場合を考えよう。 メインループが始まる前に、 \fBSIGCHLD\fP を
+\fBsigprocmask\fP(2)  でブロックする。 \fBpselect\fP()  コールでは \fBSIGCHLD\fP
+を、もともとのシグナルマスクを使って有効にするのだ。 このプログラムは次のようになる。
+.PP
+.EX
+static volatile sig_atomic_t got_SIGCHLD = 0;
+
+static void
+child_sig_handler(int sig)
+{
+    got_SIGCHLD = 1;
+}
+
+int
+main(int argc, char *argv[])
+{
+    sigset_t sigmask, empty_mask;
+    struct sigaction sa;
+    fd_set readfds, writefds, exceptfds;
+    int r;
+
+    sigemptyset(&sigmask);
+    sigaddset(&sigmask, SIGCHLD);
+    if (sigprocmask(SIG_BLOCK, &sigmask, NULL) == \-1) {
+        perror("sigprocmask");
+        exit(EXIT_FAILURE);
+    }
+
+    sa.sa_flags = 0;
+    sa.sa_handler = child_sig_handler;
+    sigemptyset(&sa.sa_mask);
+    if (sigaction(SIGCHLD, &sa, NULL) == \-1) {
+        perror("sigaction");
+        exit(EXIT_FAILURE);
+    }
+
+    sigemptyset(&empty_mask);
+
+    for (;;) {          /* main loop */
+        /* Initialize readfds, writefds, and exceptfds
+           before the pselect() call. (Code omitted.) */
+
+        r = pselect(nfds, &readfds, &writefds, &exceptfds,
+                    NULL, &empty_mask);
+        if (r == \-1 && errno != EINTR) {
+            /* Handle error */
+        }
+
+        if (got_SIGCHLD) {
+            got_SIGCHLD = 0;
+
+            /* Handle signalled event here; e.g., wait() for all
+               terminated children. (Code omitted.) */
+        }
+
+        /* main body of program */
+    }
+}
+.EE
+.SS 実例
+実際のところ \fBselect\fP()  の大事な点は何なのか? ファイルディスクリプターは好きなときに読み書きできるんじゃないの?
+\fBselect\fP()  の重要なところは、複数のディスクリプターを同時に監視でき、
+なんの動きもなければプロセスを適切にスリープ状態に移行するところにあるのだ。 UNIX プログラマは、
+複数のファイルディスクリプターの入出力を同時に扱わねばならず、 しかもデータの流れは間欠的である、という状況によく出会う。 単に \fBread\fP(2)
+や \fBwrite\fP(2)  コールのシーケンスを作るだけでは、それらのコールのどれかが ファイルディスクリプターからのデータを待ってブロックしており、
+別のファイルディスクリプターには I/O が可能なのに使えない、 ということになってしまうだろう。 \fBselect\fP()
+を使うとこの状況に効果的に対処できる。
+.SS "SELECT の掟"
+\fBselect\fP()  を使おうとした多くの人は、理解しにくい挙動に出くわし、結果的に
+できたものは移植性がないか、よくてもギリギリのものになってしまう。 例えば、上記のプログラムは、 集合に含まれるファイルディスクリプターを非停止
+(nonblocking) モード にしなくても、どこにもブロックが生じないよう注意して書かれている。 微妙な間違いによって、 \fBselect\fP()
+を使う利点は簡単に失われてしまう。 そこで、 \fBselect\fP()  コールを使うときに注意すべき重要事項を列挙しておくことにする。
+.TP  4
+1.
+\fBselect\fP()  を使うときは、タイムアウトは設定すべきでない。 処理するデータが無いときには、
+あなたのプログラムには何もすることは無いはずである。 タイムアウトに依存したコードは通常移植性がなく、 デバッグも難しくなる。
+.TP 
+2.
+上述したように、 効率的なプログラムを書くには \fInfds\fP の値を適切に計算して与えなければならない。
+.TP 
+3.
+\fBselect\fP()  コールの終了後に結果をチェックして、 適切に対応するつもりのないファイルディスクリプターは、 どの集合にも加えてはならない。
+次のルールも参照。
+.TP 
+4.
+\fBselect\fP()  から返った後には、全ての集合の全てのファイルディスクリプターについて 読み書き可能な状態になっているかをチェックすべきである。
+.TP 
+5.
+\fBread\fP(2), \fBrecv\fP(2), \fBwrite\fP(2), \fBsend\fP(2)
+といった関数は、こちらが要求した全データを読み書きする必要は\fIない\fP。 もし全データを読み書きするなら、それはトラフィックの負荷が小さく、
+ストリームが速い場合だろう。この条件は常に満たされるとは限らない。 これらの関数が頑張っても 1 バイトしか送受信できないような場合も
+考慮に入れてやらなければならない。
+.TP 
+6.
+処理するデータ量が小さいことがはっきりとわかっている場合を除いて、 一度に 1 バイトずつ読み書きするようなことはしてはならない。
+バッファーの許すかぎりのデータをまとめて読み書きしないと、 非常に効率が悪い。下記の例ではバッファーは 1024 バイトにしているが、
+このサイズを大きくするのは簡単だろう。
+.TP 
+7.
+.\" Nonetheless, you should still cope with these errors for completeness.
+Calls to \fBread\fP(2), \fBrecv\fP(2), \fBwrite\fP(2), \fBsend\fP(2), and \fBselect\fP()
+can fail with the error \fBEINTR\fP, and calls to \fBread\fP(2), \fBrecv\fP(2)
+\fBwrite\fP(2), and \fBsend\fP(2)  can fail with \fIerrno\fP set to \fBEAGAIN\fP
+(\fBEWOULDBLOCK\fP).  These results must be properly managed (not done properly
+above).  If your program is not going to receive any signals, then it is
+unlikely you will get \fBEINTR\fP.  If your program does not set nonblocking
+I/O, you will not get \fBEAGAIN\fP.
+.TP 
+8.
+決して、引き数に長さ 0 のバッファーを指定して \fBread\fP(2), \fBrecv\fP(2), \fBwrite\fP(2), \fBsend\fP(2)
+を呼び出してはならない。
+.TP 
+9.
+\fBread\fP(2), \fBrecv\fP(2), \fBwrite\fP(2), \fBsend\fP(2)  が \fB7.\fP に示した以外のエラーで失敗した場合や、
+入力系の関数の一つがファイル末尾を表す 0 を返した場合は、 そのファイルディスクリプターをもう一度 select に渡しては\fIならない\fP。
+下記の例では、そのファイルディスクリプターをただちにクローズし、 そこには \-1 をセットして、 それが集合に含まれ続けるのを許さないようにしている。
+.TP 
+10.
+タイムアウトの値は \fBselect\fP()  を呼ぶたびに初期化すべきである。 OS によっては timeout
+構造体が変更される場合があるからである。 但し、 \fBpselect\fP()  は自分の timeout 構造体を変更することはない。
+.TP 
+11.
+.\" "I have heard" does not fill me with confidence, and doesn't
+.\" belong in a man page, so I've commented this point out.
+.\" .TP
+.\" 11.
+.\" I have heard that the Windows socket layer does not cope with OOB data
+.\" properly.
+.\" It also does not cope with
+.\" .BR select ()
+.\" calls when no file descriptors are set at all.
+.\" Having no file descriptors set is a useful
+.\" way to sleep the process with subsecond precision by using the timeout.
+.\" (See further on.)
+\fBselect\fP()  はファイルディスクリプター集合を変更するので、 \fBselect\fP()
+がループの中で使用されている場合には、呼び出しを行う前に毎回 ディスクリプター集合を初期化し直さなければならない。
+.SH 返り値
+\fBselect\fP(2)  参照。
+.SH 注意
+一般的に言って、ソケットをサポートする全てのオペレーティングシステムは \fBselect\fP()  もサポートしている。 \fBselect\fP()
+を使うと、プログラマがスレッド、フォーク、IPC、シグナル、メモリー共有、 等々を使ってもっと複雑な方法で解決しようとする多くの問題が、
+移植性がありかつ効率的な方法で解決できる。
+.PP
+\fBpoll\fP(2)  システムコールは \fBselect\fP()  と同じ機能を持っており、 まばらなファイルディスクリプター集合を監視する場合に
+いくらか効率がよい。 現在では広く利用可能であるが、以前は \fBselect\fP()  より移植性の面で劣っていた。
+.PP
+Linux 独自の \fBepoll\fP(7)  API は、多数のファイルディスクリプターを監視する場合に \fBselect\fP(2)  や
+\fBpoll\fP(2)  よりも効率的なインターフェースを提供している。
+.SH 例
+\fBselect\fP()  の本当に便利な点を示す、よい例を紹介する。 以下のリストは、ある TCP ポートから別のポートへ転送を行う TCP
+フォワードプログラムである。
+.PP
+.EX
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/select.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <errno.h>
+
+static int forward_port;
+
+#undef max
+#define max(x,y) ((x) > (y) ? (x) : (y))
+
+static int
+listen_socket(int listen_port)
+{
+    struct sockaddr_in addr;
+    int lfd;
+    int yes;
+
+    lfd = socket(AF_INET, SOCK_STREAM, 0);
+    if (lfd == \-1) {
+        perror("socket");
+        return \-1;
+    }
+
+    yes = 1;
+    if (setsockopt(lfd, SOL_SOCKET, SO_REUSEADDR,
+            &yes, sizeof(yes)) == \-1) {
+        perror("setsockopt");
+        close(lfd);
+        return \-1;
+    }
+
+    memset(&addr, 0, sizeof(addr));
+    addr.sin_port = htons(listen_port);
+    addr.sin_family = AF_INET;
+    if (bind(lfd, (struct sockaddr *) &addr, sizeof(addr)) == \-1) {
+        perror("bind");
+        close(lfd);
+        return \-1;
+    }
+
+    printf("accepting connections on port %d\en", listen_port);
+    listen(lfd, 10);
+    return lfd;
+}
+
+static int
+connect_socket(int connect_port, char *address)
+{
+    struct sockaddr_in addr;
+    int cfd;
+
+    cfd = socket(AF_INET, SOCK_STREAM, 0);
+    if (cfd == \-1) {
+        perror("socket");
+        return \-1;
+    }
+
+    memset(&addr, 0, sizeof(addr));
+    addr.sin_port = htons(connect_port);
+    addr.sin_family = AF_INET;
+
+    if (!inet_aton(address, (struct in_addr *) &addr.sin_addr.s_addr)) {
+        fprintf(stderr, "inet_aton(): bad IP address format\en");
+        close(cfd);
+        return \-1;
+    }
+
+    if (connect(cfd, (struct sockaddr *) &addr, sizeof(addr)) == \-1) {
+        perror("connect()");
+        shutdown(cfd, SHUT_RDWR);
+        close(cfd);
+        return \-1;
+    }
+    return cfd;
+}
+
+#define SHUT_FD1 do {                                \e
+                     if (fd1 >= 0) {                 \e
+                         shutdown(fd1, SHUT_RDWR);   \e
+                         close(fd1);                 \e
+                         fd1 = \-1;                   \e
+                     }                               \e
+                 } while (0)
+
+#define SHUT_FD2 do {                                \e
+                     if (fd2 >= 0) {                 \e
+                         shutdown(fd2, SHUT_RDWR);   \e
+                         close(fd2);                 \e
+                         fd2 = \-1;                   \e
+                     }                               \e
+                 } while (0)
+
+#define BUF_SIZE 1024
+
+int
+main(int argc, char *argv[])
+{
+    int h;
+    int fd1 = \-1, fd2 = \-1;
+    char buf1[BUF_SIZE], buf2[BUF_SIZE];
+    int buf1_avail = 0, buf1_written = 0;
+    int buf2_avail = 0, buf2_written = 0;
+
+    if (argc != 4) {
+        fprintf(stderr, "Usage\en\etfwd <listen\-port> "
+                 "<forward\-to\-port> <forward\-to\-ip\-address>\en");
+        exit(EXIT_FAILURE);
+    }
+
+    signal(SIGPIPE, SIG_IGN);
+
+    forward_port = atoi(argv[2]);
+
+    h = listen_socket(atoi(argv[1]));
+    if (h == \-1)
+        exit(EXIT_FAILURE);
+
+    for (;;) {
+        int ready, nfds = 0;
+        ssize_t nbytes;
+        fd_set readfds, writefds, exceptfds;
+
+        FD_ZERO(&readfds);
+        FD_ZERO(&writefds);
+        FD_ZERO(&exceptfds);
+        FD_SET(h, &readfds);
+        nfds = max(nfds, h);
+
+        if (fd1 > 0 && buf1_avail < BUF_SIZE)
+            FD_SET(fd1, &readfds);
+            /* Note: nfds is updated below, when fd1 is added to
+               exceptfds. */
+        if (fd2 > 0 && buf2_avail < BUF_SIZE)
+            FD_SET(fd2, &readfds);
+
+        if (fd1 > 0 && buf2_avail \- buf2_written > 0)
+            FD_SET(fd1, &writefds);
+        if (fd2 > 0 && buf1_avail \- buf1_written > 0)
+            FD_SET(fd2, &writefds);
+
+        if (fd1 > 0) {
+            FD_SET(fd1, &exceptfds);
+            nfds = max(nfds, fd1);
+        }
+        if (fd2 > 0) {
+            FD_SET(fd2, &exceptfds);
+            nfds = max(nfds, fd2);
+        }
+
+        ready = select(nfds + 1, &readfds, &writefds, &exceptfds, NULL);
+
+        if (ready == \-1 && errno == EINTR)
+            continue;
+
+        if (ready == \-1) {
+            perror("select()");
+            exit(EXIT_FAILURE);
+        }
+
+        if (FD_ISSET(h, &readfds)) {
+            socklen_t addrlen;
+            struct sockaddr_in client_addr;
+            int fd;
+
+            addrlen = sizeof(client_addr);
+            memset(&client_addr, 0, addrlen);
+            fd = accept(h, (struct sockaddr *) &client_addr, &addrlen);
+            if (fd == \-1) {
+                perror("accept()");
+            } else {
+                SHUT_FD1;
+                SHUT_FD2;
+                buf1_avail = buf1_written = 0;
+                buf2_avail = buf2_written = 0;
+                fd1 = fd;
+                fd2 = connect_socket(forward_port, argv[3]);
+                if (fd2 == \-1)
+                    SHUT_FD1;
+                else
+                    printf("connect from %s\en",
+                            inet_ntoa(client_addr.sin_addr));
+
+                /* Skip any events on the old, closed file
+                   descriptors. */
+
+                continue;
+            }
+        }
+
+        /* NB: read OOB data before normal reads */
+
+        if (fd1 > 0 && FD_ISSET(fd1, &exceptfds)) {
+            char c;
+
+            nbytes = recv(fd1, &c, 1, MSG_OOB);
+            if (nbytes < 1)
+                SHUT_FD1;
+            else
+                send(fd2, &c, 1, MSG_OOB);
+        }
+        if (fd2 > 0 && FD_ISSET(fd2, &exceptfds)) {
+            char c;
+
+            nbytes = recv(fd2, &c, 1, MSG_OOB);
+            if (nbytes < 1)
+                SHUT_FD2;
+            else
+                send(fd1, &c, 1, MSG_OOB);
+        }
+        if (fd1 > 0 && FD_ISSET(fd1, &readfds)) {
+            nbytes = read(fd1, buf1 + buf1_avail,
+                      BUF_SIZE \- buf1_avail);
+            if (nbytes < 1)
+                SHUT_FD1;
+            else
+                buf1_avail += nbytes;
+        }
+        if (fd2 > 0 && FD_ISSET(fd2, &readfds)) {
+            nbytes = read(fd2, buf2 + buf2_avail,
+                      BUF_SIZE \- buf2_avail);
+            if (nbytes < 1)
+                SHUT_FD2;
+            else
+                buf2_avail += nbytes;
+        }
+        if (fd1 > 0 && FD_ISSET(fd1, &writefds) && buf2_avail > 0) {
+            nbytes = write(fd1, buf2 + buf2_written,
+                       buf2_avail \- buf2_written);
+            if (nbytes < 1)
+                SHUT_FD1;
+            else
+                buf2_written += nbytes;
+        }
+        if (fd2 > 0 && FD_ISSET(fd2, &writefds) && buf1_avail > 0) {
+            nbytes = write(fd2, buf1 + buf1_written,
+                       buf1_avail \- buf1_written);
+            if (nbytes < 1)
+                SHUT_FD2;
+            else
+                buf1_written += nbytes;
+        }
+
+        /* Check if write data has caught read data */
+
+        if (buf1_written == buf1_avail)
+            buf1_written = buf1_avail = 0;
+        if (buf2_written == buf2_avail)
+            buf2_written = buf2_avail = 0;
+
+        /* One side has closed the connection, keep
+           writing to the other side until empty */
+
+        if (fd1 < 0 && buf1_avail \- buf1_written == 0)
+            SHUT_FD2;
+        if (fd2 < 0 && buf2_avail \- buf2_written == 0)
+            SHUT_FD1;
+    }
+    exit(EXIT_SUCCESS);
+}
+.EE
+.PP
+上記のプログラムは、ほとんどの種類の TCP 接続をフォワードする。 \fBtelnet\fP サーバによって中継される OOB シグナルデータも扱える。
+このプログラムは、データフローを双方向に同時に送るという、 ややこしい問題も処理できる。 \fBfork\fP(2)
+コールを使って、各ストリームごとに専用のスレッドを用いるほうが効率的だ、 という人もいるかもしれない。しかし、これは考えているよりずっとややこしい。
+あるいは、 \fBfcntl\fP(2)  を使って非ブロック I/O をセットすれば良い、というアイデアもあるだろう。
+これにも実際には問題があり、タイムアウトが非効率的に起こってしまう。
+.PP
+このプログラムは一度にひとつ以上の同時接続を扱うことはできないが、 その様に拡張するのは簡単で、バッファーのリンクリストを (接続ごとにひとつずつ)
+使えばよい。 現時点のものでは、新しい接続がくると古い接続は落ちてしまう。
+.SH 関連項目
+.\" .SH AUTHORS
+.\" This man page was written by Paul Sheer.
+\fBaccept\fP(2), \fBconnect\fP(2), \fBpoll\fP(2), \fBread\fP(2), \fBrecv\fP(2),
+\fBselect\fP(2), \fBsend\fP(2), \fBsigprocmask\fP(2), \fBwrite\fP(2), \fBepoll\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
+\%https://www.kernel.org/doc/man\-pages/ に書かれている。
index 11feef1..3a88160 100644 (file)
@@ -110,11 +110,9 @@ NULL と 0 でない場合は \fBEISCONN\fP エラーも返される)。 また
 \fIflags\fP 引き数は、以下のフラグの (0 個以上の) ビット単位の論理和を とったものを指定する。
 .TP 
 \fBMSG_CONFIRM\fP (Linux 2.3.15 以降)
-Tell the link layer that forward progress happened: you got a successful
-reply from the other side.  If the link layer doesn't get this it will
-regularly reprobe the neighbor (e.g., via a unicast ARP).  Valid only on
-\fBSOCK_DGRAM\fP and \fBSOCK_RAW\fP sockets and currently implemented only for
-IPv4 and IPv6.  See \fBarp\fP(7)  for details.
+転送処理に進展があった、つまり相手側から成功の応答を受けたことをリンク層に 知らせる。リンク層がこの通知を受け取らなかった場合には、通常どおり
+(ユニキャスト ARP を使うなどの方法で) 近傍 (neighbor) の再検索を行う。 \fBSOCK_DGRAM\fP と \fBSOCK_RAW\fP
+のソケットに対してのみ有効で、現在のところ IPv4 と IPv6 のみ実装されている。 詳しくは \fBarp\fP(7)  参照のこと。
 .TP 
 \fBMSG_DONTROUTE\fP
 パケットを送り出すのにゲートウェイを使用せず、 直接接続されているネットワーク上のホストだけに送る。 通常、このフラグは診断 (diagnostic)
@@ -159,13 +157,13 @@ a process attribute that affects all threads in the process.
 .in +4n
 .EX
 struct msghdr {
-    void         *msg_name;       /* Optional address */
-    socklen_t     msg_namelen;    /* Size of address */
-    struct iovec *msg_iov;        /* Scatter/gather array */
-    size_t        msg_iovlen;     /* # elements in msg_iov */
-    void         *msg_control;    /* Ancillary data, see below */
-    size_t        msg_controllen; /* Ancillary data buffer len */
-    int           msg_flags;      /* Flags (unused) */
+    void         *msg_name;       /* 追加のアドレス */
+    socklen_t     msg_namelen;    /* アドレスのサイズ */
+    struct iovec *msg_iov;        /* scatter/gather 配列 */
+    size_t        msg_iovlen;     /* msg_iov の要素数 */
+    void         *msg_control;    /* 補助データ (後述) */
+    size_t        msg_controllen; /* 補助データバッファー長 */
+    int           msg_flags;      /* フラグ (未使用) */
 };
 .EE
 .in
@@ -218,7 +216,7 @@ on the use of ancillary data in various socket domains, see \fBunix\fP(7)  and
 Another Fast Open is in progress.
 .TP 
 \fBEBADF\fP
-\fIsockfd\fP is not a valid open file descriptor.
+\fIsockfd\fP が有効なオープンされたファイルディスクリプターでない。
 .TP 
 \fBECONNRESET\fP
 接続が接続相手によりリセットされた。
@@ -255,7 +253,7 @@ Another Fast Open is in progress.
 ソケットが接続されておらず、接続先も指定されていない。
 .TP 
 \fBENOTSOCK\fP
-The file descriptor \fIsockfd\fP does not refer to a socket.
+ファイルディスクリプター \fIsockfd\fP がソケットを参照していない。
 .TP 
 \fBEOPNOTSUPP\fP
 引き数 \fIflags\fP のいくつかのビットが、そのソケット種別では不適切なものである。
@@ -264,7 +262,7 @@ The file descriptor \fIsockfd\fP does not refer to a socket.
 接続指向のソケットでローカル側が閉じられている。 この場合、 \fBMSG_NOSIGNAL\fP が設定されていなければ、プロセスには \fBSIGPIPE\fP
 も同時に送られる。
 .SH 準拠
-4.4BSD, SVr4, POSIX.1\-2001.  These interfaces first appeared in 4.2BSD.
+4.4BSD, SVr4, POSIX.1\-2001.  (これらのインターフェースは 4.2BSD で最初に登場した)。
 .PP
 POSIX.1\-2001 には、 \fBMSG_OOB\fP と \fBMSG_EOR\fP フラグだけが記載されている。 POSIX.1\-2008 では
 \fBMSG_NOSIGNAL\fP が規格に追加されている。 \fBMSG_CONFIRM\fP フラグは Linux での拡張である。
@@ -283,7 +281,7 @@ should be typed as \fIint\fP, but glibc currently types both as \fIsize_t\fP.
 Linux 固有の システムコールに関する情報が書かれている。
 .SH バグ
 Linux は \fBENOTCONN\fP を返す状況で \fBEPIPE\fP を返すことがある。
-.SH EXAMPLES
+.SH 
 \fBsendto\fP()  の利用例が \fBgetaddrinfo\fP(3)  に記載されている。
 .SH 関連項目
 \fBfcntl\fP(2), \fBgetsockopt\fP(2), \fBrecv\fP(2), \fBselect\fP(2), \fBsendfile\fP(2),
index 85bed54..fd8a8ad 100644 (file)
@@ -91,8 +91,7 @@ struct mmsghdr {
 .\"
 .\"     This matches the behavior of other syscalls like read/write - it
 .\"     is not an error if less than the requested number of elements are sent.
-Errors are as for \fBsendmsg\fP(2).  An error is returned only if no datagrams
-could be sent.  See also BUGS.
+エラーは \fBsendmsg\fP(2) と同じである。 エラーが返されるのは、 データグラムが全く送信できなかった場合のみである。「バグ」も参照のこと。
 .SH バージョン
 \fBsendmmsg\fP() システムコールは Linux 3.0 で追加された。 glibc でのサポートはバージョン 2.14 で追加された。
 .SH 準拠
@@ -114,7 +113,7 @@ succeeds, and returns the number of messages sent.  The error code is lost.
 The caller can retry the transmission, starting at the first failed message,
 but there is no guarantee that, if an error is returned, it will be the same
 as the one that was lost on the previous call.
-.SH EXAMPLES
+.SH 
 以下の例では、 \fBsendmmsg\fP() を使って、 一度のシステムコールで、 \fIonetwo\fP と \fIthree\fP を二つの別々の UDP
 データグラムで送信する。 一つ目のデータグラムの内容は、二つのバッファーから取得される。
 .PP
diff --git a/manual/LDP_man-pages/draft/man2/socket.2 b/manual/LDP_man-pages/draft/man2/socket.2
new file mode 100644 (file)
index 0000000..b617ce0
--- /dev/null
@@ -0,0 +1,378 @@
+.\" Copyright (c) 1983, 1991 The Regents of the University of California.
+.\" 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:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by the University of
+.\"    California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" 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: socket.2,v 1.4 1999/05/13 11:33:42 freitag Exp $
+.\"
+.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
+.\" Modified 1996-10-22 by Eric S. Raymond <esr@thyrsus.com>
+.\" Modified 1998, 1999 by Andi Kleen <ak@muc.de>
+.\" Modified 2002-07-17 by Michael Kerrisk <mtk.manpages@gmail.com>
+.\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com>
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
+.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
+.\"         all rights reserved.
+.\" Translated Mon Mar  3 23:40:11 JST 1997
+.\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
+.\" Modified Sun Aug 15 23:52:28 JST 1999
+.\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
+.\" Updated Mon Jan 13 JST 2000 by Kentaro Shirakata <argrath@ub32.org>
+.\" Updated Mon Oct 15 JST 2001 by Kentaro Shirakata <argrath@ub32.org>
+.\" Updated Mon Oct 26 JST 2002 by Kentaro Shirakata <argrath@ub32.org>
+.\" Updated 2008-11-09, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.13
+.\" Updated 2012-05-29, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-03-25, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-05-06, Akihiro MOTOKI <amotoki@gmail.com>
+.\"
+.TH SOCKET 2 2020\-06\-09 Linux "Linux Programmer's Manual"
+.SH 名前
+socket \- 通信のための端点 (endpoint) を作成する
+.SH 書式
+\fB#include <sys/types.h>\fP /* 「注意」参照 */
+.br
+\fB#include <sys/socket.h>\fP
+.PP
+\fBint socket(int \fP\fIdomain\fP\fB, int \fP\fItype\fP\fB, int \fP\fIprotocol\fP\fB);\fP
+.SH 説明
+\fBsocket\fP()  creates an endpoint for communication and returns a file
+descriptor that refers to that endpoint.  The file descriptor returned by a
+successful call will be the lowest\-numbered file descriptor not currently
+open for the process.
+.PP
+\fIdomain\fP 引数は通信を行なうドメインを指定する; これはどの プロトコルファミリー (protocol family)
+を通信に使用するかを指定する。 これらのファミリーは \fI<sys/socket.h>\fP
+に定義されている。現在カーネルが理解できるフォーマットは以下の通り。
+.TS
+tab(:);
+l1 lw40 l.
+名前:目的:マニュアル
+T{
+\fBAF_UNIX\fP
+T}:T{
+ローカル通信
+T}:T{
+\fBunix\fP(7)
+T}
+T{
+\fBAF_LOCAL\fP
+T}:T{
+Synonym for
+\fBAF_UNIX\fP
+T}:T{
+T}
+T{
+\fBAF_INET\fP
+T}:IPv4 インターネットプロトコル:T{
+\fBip\fP(7)
+T}
+T{
+\fBAF_AX25\fP
+T}:T{
+アマチュア無線 AX.25 プロトコル
+T}:T{
+.\" Part of ax25-tools
+\fBax25\fP(4)
+T}
+T{
+\fBAF_IPX\fP
+T}:IPX \- Novell プロトコル:
+T{
+\fBAF_APPLETALK\fP
+T}:AppleTalk:T{
+\fBddp\fP(7)
+T}
+T{
+\fBAF_X25\fP
+T}:ITU\-T X.25 / ISO\-8208 プロトコル:T{
+\fBx25\fP(7)
+T}
+T{
+\fBAF_INET6\fP
+T}:IPv6 インターネットプロトコル:T{
+\fBipv6\fP(7)
+T}
+T{
+\fBAF_DECnet\fP
+T}:T{
+DECet protocol sockets
+T}
+T{
+\fBAF_KEY\fP
+T}:T{
+Key management protocol, originally developed for usage with IPsec
+T}
+T{
+\fBAF_NETLINK\fP
+T}:T{
+カーネルユーザーインターフェースデバイス
+T}:T{
+\fBnetlink\fP(7)
+T}
+T{
+\fBAF_PACKET\fP
+T}:T{
+低レベルのパケットインターフェース
+T}:T{
+\fBpacket\fP(7)
+T}
+T{
+\fBAF_RDS\fP
+T}:T{
+.\" commit: 639b321b4d8f4e412bfbb2a4a19bfebc1e68ace4
+Reliable Datagram Sockets (RDS) protocol
+T}:T{
+.\" rds-tools: https://github.com/oracle/rds-tools/blob/master/rds.7
+.\" rds-tools: https://github.com/oracle/rds-tools/blob/master/rds-rdma.7
+\fBrds\fP(7)
+.br
+\fBrds\-rdma\fP(7)
+T}
+T{
+\fBAF_PPPOX\fP
+T}:T{
+Generic PPP transport layer, for setting up L2 tunnels
+(L2TP and PPPoE)
+T}
+T{
+\fBAF_LLC\fP
+T}:T{
+.\" linux-history commit: 34beb106cde7da233d4df35dd3d6cf4fee937caa
+Logical link control (IEEE 802.2 LLC) protocol
+T}
+T{
+\fBAF_IB\fP
+T}:T{
+.\" commits: 8d36eb01da5d371f..ce117ffac2e93334
+InfiniBand native addressing
+T}
+T{
+\fBAF_MPLS\fP
+T}:T{
+.\" commits: 0189197f441602acdca3f97750d392a895b778fd
+Multiprotocol Label Switching
+T}
+T{
+\fBAF_CAN\fP
+T}:T{
+.\" commits: 8dbde28d9711475a..5423dd67bd0108a1
+Controller Area Network automotive bus protocol
+T}
+T{
+\fBAF_TIPC\fP
+T}:T{
+.\" commits: b97bf3fd8f6a16966d4f18983b2c40993ff937d4
+TIPC, "cluster domain sockets" protocol
+T}
+T{
+\fBAF_BLUETOOTH\fP
+T}:T{
+.\" commits: 8d36eb01da5d371f..ce117ffac2e93334
+Bluetooth low\-level socket protocol
+T}
+T{
+\fBAF_ALG\fP
+T}:T{
+.\" commit: 03c8efc1ffeb6b82a22c1af8dd908af349563314
+カーネルの暗号 API へのインターフェース
+T}
+T{
+\fBAF_VSOCK\fP
+T}:T{
+.\" commit: d021c344051af91f42c5ba9fdedc176740cbd238
+VSOCK (originally "VMWare VSockets") protocol
+for hypervisor\-guest communication
+T}:T{
+\fBvsock\fP(7)
+T}
+T{
+\fBAF_KCM\fP
+T}:T{
+.\" commit: 03c8efc1ffeb6b82a22c1af8dd908af349563314
+KCM (kernel connection multiplexer) interface
+T}
+T{
+\fBAF_XDP\fP
+T}:T{
+.\" commit: c0c77d8fb787cfe0c3fca689c2a30d1dad4eaba7
+XDP (express data path) interface
+T}
+.TE
+.PP
+Further details of the above address families, as well as information on
+several other address families, can be found in \fBaddress_families\fP(7).
+.PP
+ソケットは \fItype\fP で指定される型を持ち、それは通信方式 (semantics) を指定する。 定義されている型は現在以下の通り。
+.TP  16
+\fBSOCK_STREAM\fP
+順序性と信頼性があり、双方向の、接続された バイトストリーム (byte stream) を提供する。 帯域外 (out\-of\-band)
+データ転送メカニズムもサポートされる。
+.TP 
+\fBSOCK_DGRAM\fP
+データグラム (コネクションレス、信頼性無し、固定最大長メッセージ) をサポートする。
+.TP 
+\fBSOCK_SEQPACKET\fP
+固定最大長のデータグラム転送パスに基づいた順序性、信頼性のある 双方向の接続に基づいた通信を提供する。受け取り側ではそれぞれの入力
+システムコールでパケット全体を読み取ることが要求される。
+.TP 
+\fBSOCK_RAW\fP
+生のネットワークプロトコルへのアクセスを提供する。
+.TP 
+\fBSOCK_RDM\fP
+信頼性はあるが、順序は保証しないデータグラム層を提供する。
+.TP 
+\fBSOCK_PACKET\fP
+廃止されており新しいプログラムで使用してはいけない。 \fBpacket\fP(7)  を参照すること
+.PP
+ある種のソケット型が全てのプロトコルファミリーで実装されているわけではない。
+.PP
+Linux 2.6.27 以降では、 \fItype\fP 引数は二つ目の目的にも使用される。 ソケットの型を指定するのに加えて、
+以下の値のいくつかをビット単位の論理和 (OR) で指定することで、 \fBsocket\fP()  の振舞いを変更することができる。
+.TP  16
+\fBSOCK_NONBLOCK\fP
+Set the \fBO_NONBLOCK\fP file status flag on the open file description (see
+\fBopen\fP(2))  referred to by the new file descriptor.  Using this flag saves
+extra calls to \fBfcntl\fP(2)  to achieve the same result.
+.TP 
+\fBSOCK_CLOEXEC\fP
+新しいファイルディスクリプターに対して close\-on\-exec (\fBFD_CLOEXEC\fP)  フラグをセットする。
+このフラグが役に立つ理由については、 \fBopen\fP(2)  の \fBO_CLOEXEC\fP フラグの説明を参照のこと。
+.PP
+\fIprotocol\fP はソケットによって使用される固有のプロトコルを指定する。通常それぞれの
+ソケットは、与えられたプロトコルファミリーの種類ごとに一つのプロトコルのみを サポートする。 その場合は \fIprotocol\fP に 0 を指定できる。
+しかし、多くのプロトコルが存在してもかまわない。 この場合にはこの方法により固有のプロトコルを指定する必要がある。
+使用されるプロトコル番号は通信の行なわれる\*(lq通信ドメイン\*(rqに 固有である; \fBprotocols\fP(5)  を参照すること。
+プロトコル名をどうやってプロトコル番号に対応させるかについては \fBgetprotoent\fP(3)  を参照すること。
+.PP
+\fBSOCK_STREAM\fP 型のソケットは全二重バイトストリームである。 これらはレコード境界を保存しない。
+ストリームは、ソケットがデータを送ったり受けたりする前に \fI接続された\fP 状態になってなければならない。他のソケットへの接続は
+\fBconnect\fP(2)  コールによって行なわれる。一度接続したらデータは \fBread\fP(2)  と \fBwrite\fP(2)  コールや
+\fBsend\fP(2)  と \fBrecv\fP(2)  コールの変種を使用して転送できる。 セッションが完了したら \fBclose\fP(2)
+が行なわれる。帯域外データの転送も \fBsend\fP(2)  に記述されており、 受信も \fBrecv\fP(2)  に記述されている。
+.PP
+\fBSOCK_STREAM\fP を実装した通信プロトコルはデータに損失や重複がないことを保証する。 もし相手のプロトコルがバッファー空間を持つ
+データの断片を適当な時間のうちに転送できなければ、 接続は断たれたとみなす。そのソケット \fBSO_KEEPALIVE\fP
+が有効になっている場合、プロトコル独自の方法で接続の相手側がまだ 有効であるかをチェックする。
+もしプロセスが、壊れたストリームでデータを送受信しようとした場合には \fBSIGPIPE\fP シグナルが送られる;
+これは通常のそのシグナルを扱っていないプロセスを 終了させる。 \fBSOCK_SEQPACKET\fP ソケットは \fBSOCK_STREAM\fP
+ソケットと同じシステムコールを使用する。 唯一の違いは \fBread\fP(2)  コールが要求された量のデータのみを返し、到着したパケットの残りの部分を
+捨ててしまうことである。同様に入ってくるデータグラムの全てのメッセージ境界は 保存される。
+.PP
+\fBSOCK_DGRAM\fP と \fBSOCK_RAW\fP ソケットは \fBsendto\fP(2)
+コールで指定された相手へデータグラムを送ることが許されている。 データグラムは一般に \fBrecvfrom\fP(2)  で受けとり、
+このコールは次のデータグラムを送信者のアドレスと一緒に返す。
+.PP
+\fBSOCK_PACKET\fP は古いソケット型で、生(raw)のパケットをデバイスドライバから 直接受信するためのものである。 今は代わりに
+\fBpacket\fP(7)  を用いること。
+.PP
+\fBfcntl\fP(2)  の \fBF_SETOWN\fP 操作を使って、シグナル \fBSIGURG\fP や \fBSIGPIPE\fP
+を受けとるプロセスグループを指定できる。 \fBSIGURG\fP シグナルは帯域外データが到着した時に、 \fBSIGPIPE\fP シグナルは
+\fBSOCK_STREAM\fP 接続が予期せず切断された時に送られる。 また、 \fBF_SETOWN\fP 操作は、I/O や I/O イベントの非同期
+(asynchronous) 通知を \fBSIGIO\fP を経由で受け取るプロセスやプロセスグループを設定するのにも使用できる。 \fBF_SETOWN\fP
+を使用することは \fBFIOSETOWN\fP または \fBSIOCSPGRP\fP の引数で \fBioctl\fP(2)  を使用することと等価である。
+.PP
+ネットワークがプロトコルモジュールにエラー状態を伝えた場合 (例えば、IP の ICMP メッセージを使用して)には、ソケットの
+ペンディングエラーフラグが設定される。次にこのソケットを操作した 時にペンディングされていたエラーコードが返される。プロトコルによっては
+エラーについてのより詳しい情報を受け取るためにソケットごとのエラーキューを 受け取ることが可能である。 \fBip\fP(7)  の
+\fBIP_RECVERR\fP を参照すること。
+.PP
+ソケットの操作はソケットレベル \fIoptions\fP によって制御される。 これらのオプションは \fI<sys/socket.h>\fP
+に定義されている。 \fBsetsockopt\fP(2)  と \fBgetsockopt\fP(2)  関数はそれぞれオプションの設定と取得を行なう。
+.SH 返り値
+成功した場合、新しいソケットのファイルディスクリプターを返す。 エラーが発生した場合は \-1 を返し、 \fIerrno\fP を適切に設定する。
+.SH エラー
+.TP 
+\fBEACCES\fP
+指定されたタイプまたはプロトコルのソケットを作成する許可が与えられていない。
+.TP 
+\fBEAFNOSUPPORT\fP
+指定されたアドレスファミリーがサポートされていない。
+.TP 
+\fBEINVAL\fP
+知らないプロトコル、または利用できないプロトコルファミリーである。
+.TP 
+\fBEINVAL\fP
+.\" Since Linux 2.6.27
+\fItype\fP に無効なフラグが指定されている。
+.TP 
+\fBEMFILE\fP
+1プロセスがオープンできるファイルディスクリプター数の上限に達した。
+.TP 
+\fBENFILE\fP
+オープンされたファイルの総数がシステム全体の上限に達していた。
+.TP 
+\fBENOBUFS\fP または \fBENOMEM\fP
+十分なメモリーがない。十分な資源が解放されるまではソケットを 作成することはできない。
+.TP 
+\fBEPROTONOSUPPORT\fP
+このドメインでは指定されたプロトコルまたはプロトコルタイプが サポートされていない。
+.PP
+下位のプロトコルモジュールから他のエラーが生成されるかもしれない。
+.SH 準拠
+POSIX.1\-2001, POSIX.1\-2008, 4.4BSD.
+.PP
+フラグ \fBSOCK_NONBLOCK\fP, \fBSOCK_CLOEXEC\fP は Linux 固有である。
+.PP
+\fBsocket\fP()  は 4.2BSD で登場した。一般に、(System\ V の変種を含めて)  BSD のソケット層の互換性をサポートしている
+BSD 以外のシステムへの、 または、BSD 以外のシステムからの移植ができる。
+.SH 注意
+POSIX.1 では \fI<sys/types.h>\fP のインクルードは必須とされておらず、 Linux
+ではこのヘッダーファイルは必要ではない。 しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダーファイルが
+必要であり、移植性が必要なアプリケーションではこのファイルを インクルードするのが賢明であろう。
+.PP
+4.x BSD において定数を使用する場合、プロトコルファミリーには
+\fBPF_UNIX\fP, \fBPF_INET\fP 等を使用している。一方でアドレスファミリーには
+\fBAF_UNIX\fP, \fBAF_INET\fP 等が使用されている。
+しかしながら BSD のマニュアルでは 「一般にプロトコルファミリーは
+アドレスファミリーと同じものである。」 と保証している。
+それ以外の規格では全ての場所で AF_* が使用されている。
+.SH 例
+\fBsocket\fP()  の利用例が \fBgetaddrinfo\fP(3)  に記載されている。
+.SH 関連項目
+\fBaccept\fP(2), \fBbind\fP(2), \fBclose\fP(2), \fBconnect\fP(2), \fBfcntl\fP(2),
+\fBgetpeername\fP(2), \fBgetsockname\fP(2), \fBgetsockopt\fP(2), \fBioctl\fP(2),
+\fBlisten\fP(2), \fBread\fP(2), \fBrecv\fP(2), \fBselect\fP(2), \fBsend\fP(2),
+\fBshutdown\fP(2), \fBsocketpair\fP(2), \fBwrite\fP(2), \fBgetprotoent\fP(3),
+\fBaddress_families\fP(7), \fBip\fP(7), \fBsocket\fP(7), \fBtcp\fP(7), \fBudp\fP(7),
+\fBunix\fP(7)
+.PP
+\(lqAn Introductory 4.3BSD Interprocess Communication Tutorial\(rq and
+\(lqBSD Interprocess Communication Tutorial\(rq, (\fIUNIX Programmer's
+Supplementary Documents Volume 1.\fP として再版された)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
+\%https://www.kernel.org/doc/man\-pages/ に書かれている。
diff --git a/manual/LDP_man-pages/draft/man2/socketcall.2 b/manual/LDP_man-pages/draft/man2/socketcall.2
new file mode 100644 (file)
index 0000000..a6a5b64
--- /dev/null
@@ -0,0 +1,177 @@
+.\" Copyright (c) 1995 Michael Chastain (mec@shell.portal.com), 15 April 1995.
+.\"
+.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
+.\" This is free documentation; you can redistribute it and/or
+.\" modify it under the terms of the GNU General Public License as
+.\" published by the Free Software Foundation; either version 2 of
+.\" the License, or (at your option) any later version.
+.\"
+.\" The GNU General Public License's references to "object code"
+.\" and "executables" are to be interpreted as the output of any
+.\" document formatting or typesetting system, including
+.\" intermediate and printed output.
+.\"
+.\" This manual is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public
+.\" License along with this manual; if not, see
+.\" <http://www.gnu.org/licenses/>.
+.\" %%%LICENSE_END
+.\"
+.\" Modified Tue Oct 22 22:11:53 1996 by Eric S. Raymond <esr@thyrsus.com>
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
+.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
+.\"         all rights reserved.
+.\" Translated Mon Mar  3 23:45:10 JST 1997
+.\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
+.\" Updated 2013-03-26, Akihiro MOTOKI <amotoki@gmail.com>
+.\"
+.TH SOCKETCALL 2 2017\-09\-15 Linux "Linux Programmer's Manual"
+.SH 名前
+socketcall \- ソケットシステムコール
+.SH 書式
+\fB#include <linux/net.h>\fP
+.PP
+\fBint socketcall(int \fP\fIcall\fP\fB, unsigned long *\fP\fIargs\fP\fB);\fP
+.SH 説明
+\fBsocketcall\fP()  はソケットシステムコールのための共通のカーネルエントリー ポイント(kernel entry point)である。
+\fIcall\fP はどのソケット関数を呼び出すかを指定する。 \fIargs\fP は適切なコールに渡すための実際の引き数を含んでいるブロックを指す。
+.PP
+ユーザープログラムは通常の名前を使用して適切な関数を呼び出すべきである。 標準ライブラリの実装者やカーネルハッカーのみが \fBsocketcall\fP()
+について知る必要がある。
+.PP
+.TS
+tab(:);
+l l.
+\fIcall\fP:マニュアル
+T{
+\fBSYS_SOCKET\fP
+T}:T{
+\fBsocket\fP(2)
+T}
+T{
+\fBSYS_BIND\fP
+T}:T{
+\fBbind\fP(2)
+T}
+T{
+\fBSYS_CONNECT\fP
+T}:T{
+\fBconnect\fP(2)
+T}
+T{
+\fBSYS_LISTEN\fP
+T}:T{
+\fBlisten\fP(2)
+T}
+T{
+\fBSYS_ACCEPT\fP
+T}:T{
+\fBaccept\fP(2)
+T}
+T{
+\fBSYS_GETSOCKNAME\fP
+T}:T{
+\fBgetsockname\fP(2)
+T}
+T{
+\fBSYS_GETPEERNAME\fP
+T}:T{
+\fBgetpeername\fP(2)
+T}
+T{
+\fBSYS_SOCKETPAIR\fP
+T}:T{
+\fBsocketpair\fP(2)
+T}
+T{
+\fBSYS_SEND\fP
+T}:T{
+\fBsend\fP(2)
+T}
+T{
+\fBSYS_RECV\fP
+T}:T{
+\fBrecv\fP(2)
+T}
+T{
+\fBSYS_SENDTO\fP
+T}:T{
+\fBsendto\fP(2)
+T}
+T{
+\fBSYS_RECVFROM\fP
+T}:T{
+\fBrecvfrom\fP(2)
+T}
+T{
+\fBSYS_SHUTDOWN\fP
+T}:T{
+\fBshutdown\fP(2)
+T}
+T{
+\fBSYS_SETSOCKOPT\fP
+T}:T{
+\fBsetsockopt\fP(2)
+T}
+T{
+\fBSYS_GETSOCKOPT\fP
+T}:T{
+\fBgetsockopt\fP(2)
+T}
+T{
+\fBSYS_SENDMSG\fP
+T}:T{
+\fBsendmsg\fP(2)
+T}
+T{
+\fBSYS_RECVMSG\fP
+T}:T{
+\fBrecvmsg\fP(2)
+T}
+T{
+\fBSYS_ACCEPT4\fP
+T}:T{
+\fBaccept4\fP(2)
+T}
+T{
+\fBSYS_RECVMMSG\fP
+T}:T{
+\fBrecvmmsg\fP(2)
+T}
+T{
+\fBSYS_SENDMMSG\fP
+T}:T{
+\fBsendmmsg\fP(2)
+T}
+.TE
+.SH 準拠
+このコールは Linux 特有であり、移植を意図したプログラムで 使用してはいけない。
+.SH 注意
+いくつかのアーキテクチャー\\(emfor 例えば x86\-64 や ARM\\(emでは、システムコール \fBsocketcall\fP()
+が存在しない。実際には、その代わりに \fBsocket\fP(2), \fBaccept\fP(2), \fBbind\fP(2)
+などが独立したシステムコールとして実装されている。
+.PP
+.\" commit 9dea5dc921b5f4045a18c63eb92e84dc274d17eb
+On x86\-32, \fBsocketcall\fP()  was historically the only entry point for the
+sockets API.  However, starting in Linux 4.3, direct system calls are
+provided on x86\-32 for the sockets API.  This facilitates the creation of
+\fBseccomp\fP(2)  filters that filter sockets system calls (for new user\-space
+binaries that are compiled to use the new entry points)  and also provides a
+(very) small performance improvement.
+.SH 関連項目
+\fBaccept\fP(2), \fBbind\fP(2), \fBconnect\fP(2), \fBgetpeername\fP(2),
+\fBgetsockname\fP(2), \fBgetsockopt\fP(2), \fBlisten\fP(2), \fBrecv\fP(2),
+\fBrecvfrom\fP(2), \fBrecvmsg\fP(2), \fBsend\fP(2), \fBsendmsg\fP(2), \fBsendto\fP(2),
+\fBsetsockopt\fP(2), \fBshutdown\fP(2), \fBsocket\fP(2), \fBsocketpair\fP(2)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
+\%https://www.kernel.org/doc/man\-pages/ に書かれている。
diff --git a/manual/LDP_man-pages/draft/man2/socketpair.2 b/manual/LDP_man-pages/draft/man2/socketpair.2
new file mode 100644 (file)
index 0000000..a24a184
--- /dev/null
@@ -0,0 +1,117 @@
+.\" Copyright (c) 1983, 1991 The Regents of the University of California.
+.\" 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:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by the University of
+.\"    California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" 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
+.\"
+.\"     @(#)socketpair.2       6.4 (Berkeley) 3/10/91
+.\"
+.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
+.\" Modified 1996-10-22 by Eric S. Raymond <esr@thyrsus.com>
+.\" Modified 2002-07-22 by Michael Kerrisk <mtk.manpages@gmail.com>
+.\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com>
+.\" 2008-10-11, mtk: Add description of SOCK_NONBLOCK and SOCK_CLOEXEC
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
+.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
+.\"         all rights reserved.
+.\" Translated 1997-03-03, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
+.\" Updated 2002-09-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
+.\" Updated 2005-02-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
+.\" Updated 2008-11-09, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.13
+.\"
+.TH SOCKETPAIR 2 2020\-06\-09 Linux "Linux Programmer's Manual"
+.SH 名前
+socketpair \- 接続されたソケットのペアを作成する
+.SH 書式
+\fB#include <sys/types.h>\fP /* 「注意」参照 */
+.br
+\fB#include <sys/socket.h>\fP
+.PP
+\fBint socketpair(int \fP\fIdomain\fP\fB, int \fP\fItype\fP\fB, int \fP\fIprotocol\fP\fB, int
+\fP\fIsv\fP\fB[2]);\fP
+.SH 説明
+\fBsocketpair\fP()  は、指定されたドメイン \fIdomain\fP に指定された種類 \fItype\fP
+で名前のないソケットの接続されたペアを作成する。 \fIprotocol\fP が指定されると、このプロトコルを用いる。 これらの引き数の詳細は
+\fBsocket\fP(2)  を参照のこと。
+.PP
+The file descriptors used in referencing the new sockets are returned in
+\fIsv[0]\fP and \fIsv[1]\fP.  The two sockets are indistinguishable.
+.SH 返り値
+On success, zero is returned.  On error, \-1 is returned, \fIerrno\fP is set
+appropriately, and \fIsv\fP is left unchanged
+.PP
+.\" http://austingroupbugs.net/view.php?id=483
+On Linux (and other systems), \fBsocketpair\fP()  does not modify \fIsv\fP on
+failure.  A requirement standardizing this behavior was added in
+POSIX.1\-2008 TC2.
+.SH エラー
+.TP 
+\fBEAFNOSUPPORT\fP
+このマシンでは指定されたアドレスファミリーがサポートされていない。
+.TP 
+\fBEFAULT\fP
+アドレス \fIsv\fP がこのプロセスで使えるアドレス空間を指定していない。
+.TP 
+\fBEMFILE\fP
+1プロセスがオープンできるファイルディスクリプター数の上限に達した。
+.TP 
+\fBENFILE\fP
+オープンされたファイルの総数がシステム全体の上限に達していた。
+.TP 
+\fBEOPNOTSUPP\fP
+指定されたプロトコルではソケットのペアの作成がサポートされていない。
+.TP 
+\fBEPROTONOSUPPORT\fP
+このマシンでは指定されたプロトコルがサポートされていない。
+.SH 準拠
+POSIX.1\-2001, POSIX.1\-2008, 4.4BSD.  \fBsocketpair\fP() は 4.2BSD で登場した。一般に
+(System\ V の変種を含めて)  BSD のソケット層のクローンをサポートしている、BSD 以外のシステムと、 互いに移植性がある。
+.SH 注意
+.\" commit: 70b03759e9ecfae400605fa34f3d7154cccbbba3
+On Linux, the only supported domains for this call are \fBAF_UNIX\fP (or
+synonymously, \fBAF_LOCAL\fP)  and \fBAF_TIPC\fP (since Linux 4.12).
+.PP
+Since Linux 2.6.27, \fBsocketpair\fP()  supports the \fBSOCK_NONBLOCK\fP and
+\fBSOCK_CLOEXEC\fP flags in the \fItype\fP argument, as described in \fBsocket\fP(2).
+.PP
+POSIX.1 では \fI<sys/types.h>\fP のインクルードは必須とされておらず、 Linux
+ではこのヘッダーファイルは必要ではない。 しかし、歴史的には、いくつかの実装 (BSD 系) でこのヘッダーファイルが
+必要であり、移植性が必要なアプリケーションではこのファイルを インクルードするのが賢明であろう。
+.SH 関連項目
+\fBpipe\fP(2), \fBread\fP(2), \fBsocket\fP(2), \fBwrite\fP(2), \fBsocket\fP(7), \fBunix\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
+\%https://www.kernel.org/doc/man\-pages/ に書かれている。
index c396936..c03c360 100644 (file)
@@ -134,13 +134,11 @@ T}        Thread safety   MT\-Safe
 .\" appears to be confused and obsolete on this point.
 .\" i.e., commonly it still says one of them will be NULL, even if
 .\" the ifa_ifu union is already present
-Not in POSIX.1.  This function first appeared in BSDi and is present on the
-BSD systems, but with slightly different semantics documented\(emreturning
-one entry per interface, not per address.  This means \fIifa_addr\fP and other
-fields can actually be NULL if the interface has no address, and no
-link\-level address is returned if the interface has an IP address assigned.
-Also, the way of choosing either \fIifa_broadaddr\fP or \fIifa_dstaddr\fP differs
-on various systems.
+POSIX.1 にはない。 この関数は BSDi で初めて登場し、 BSD 系のシステムに存在するが、
+ドキュメント上はかなり動作が異なり、アドレス毎ではなくインターフェース毎に 1 エントリーを返す。 このことは、
+インターフェースがアドレスを持たない場合には \fIifa_addr\fP や他のフィールドは実際に NULL になり、 インターフェースに IP
+アドレスが割り当てられている場合には リンクレベルのアドレスは返されない、ということを意味する。 また、 \fIifa_broadaddr\fP と
+\fIifa_dstaddr\fP のどちらを選択するかを決める方法は、 システムにより異なる。
 .SH 注意
 Linux では、 返されるアドレスは通常インターフェースに割り当てられた IPv4 アドレスと IPv6 アドレスになるが、
 これ以外にインターフェース毎に一つ \fBAF_PACKET\fP アドレスも返される。 \fBAF_PACKET\fP アドレスには、
@@ -148,7 +146,7 @@ Linux では、 返されるアドレスは通常インターフェースに割
 \fI<linux/if_link.h>\fP で定義される \fIstruct rtnl_link_stats\fP (Linux 2.4
 以前では \fI<linux/netdevice.h>\fP で定義される \fIstruct net_device_stats\fP)
 へのポインターが格納される。 この構造体には、インターフェースの様々な属性や統計情報が入る。
-.SH EXAMPLES
+.SH 
 以下のプログラムは \fBgetifaddrs\fP(), \fBfreeifaddrs\fP(), \fBgetnameinfo\fP(3) の使用例である。
 以下はこのプログラムをあるシステムで実行した際の出力である。
 .PP
index 4b311cc..b0bc1aa 100644 (file)
@@ -50,14 +50,13 @@ if_nameindex, if_freenameindex \- ネットワークインターフェースの
 .PP
 .in +4n
 .EX
-unsigned int if_index; /* Index of interface (1, 2, ...) */
-char        *if_name;  /* Null\-terminated name ("eth0", etc.) */
+unsigned int if_index; /* インターフェースのインデックス (1, 2, ...) */
+char        *if_name;  /*ヌル終端された名前 ("eth0" など) */
 .EE
 .in
 .PP
-The \fIif_index\fP field contains the interface index.  The \fIif_name\fP field
-points to the null\-terminated interface name.  The end of the array is
-indicated by entry with \fIif_index\fP set to zero and \fIif_name\fP set to NULL.
+\fIif_index\fP フィールドにはインターフェースのインデックスが入る。 \fIif_name\fP フィールドはヌル終端されたインターフェース名を指す。
+配列の最後は、 \fIif_index\fP が 0 で \fIif_name\fP が NULL のエントリーで示される。
 .PP
 \fBif_nameindex\fP() が返すデータ構造体は動的に確保される。 必要なくなった際には \fBif_freenameindex\fP()
 で解放すべきである。
@@ -95,7 +94,7 @@ T}    Thread safety   MT\-Safe
 POSIX.1\-2001, POSIX.1\-2008, RFC\ 3493.
 .PP
 この関数は BSDi 初めて登場した。
-.SH EXAMPLES
+.SH 
 以下のプログラムはこのページで説明した関数の使い方を示している。このプログラムが生成する出力は以下のようになる。
 .PP
 .in +4n
index c50607d..8af8034 100644 (file)
@@ -56,10 +56,10 @@ if_nametoindex, if_indextoname \- ネットワークインターフェースの
 成功した場合には \fBif_indextoname\fP() は \fIifname\fP を返す。エラー時には NULL が返され、 \fIerrno\fP
 が適切に設定される。
 .SH エラー
-\fBif_nametoindex\fP()  may fail and set \fIerrno\fP if:
+\fBif_nametoindex\fP() が失敗した場合には以下の \fIerrno\fP が設定される。
 .TP 
 \fBENODEV\fP
-No interface found with given name.
+指定された名前を持つインターフェースがない。
 .PP
 \fBif_indextoname\fP() は以下の \fIerrno\fP で失敗する場合がある。
 .TP 
index 9834d11..8c28a9a 100644 (file)
@@ -87,7 +87,7 @@ POSIX.1\-2001, POSIX.1\-2008.
 \fBsockatmark\fP()  は \fBSIOCATMARK\fP \fBioctl\fP(2)  操作を使って実装されている。
 .SH バグ
 glibc 2.4 より前のバージョンでは、 \fBsockatmark\fP()  は動作しない。
-.SH EXAMPLES
+.SH 
 以下のコードは、 \fBSIGURG\fP シグナルを受け取った後にマークまでの全てのデータを読み込んで (破棄し)、
 マークされたデータのバイトを読み込むのに使用できる。
 .PP
diff --git a/manual/LDP_man-pages/draft/man7/socket.7 b/manual/LDP_man-pages/draft/man7/socket.7
new file mode 100644 (file)
index 0000000..6973915
--- /dev/null
@@ -0,0 +1,740 @@
+.\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
+.\" and copyright (c) 1999 Matthew Wilcox.
+.\"
+.\" %%%LICENSE_START(VERBATIM_ONE_PARA)
+.\" Permission is granted to distribute possibly modified copies
+.\" of this page provided the header is included verbatim,
+.\" and in case of nontrivial modification author and date
+.\" of the modification is added to the header.
+.\" %%%LICENSE_END
+.\"
+.\" 2002-10-30, Michael Kerrisk, <mtk.manpages@gmail.com>
+.\"    Added description of SO_ACCEPTCONN
+.\" 2004-05-20, aeb, added SO_RCVTIMEO/SO_SNDTIMEO text.
+.\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
+.\"     Added notes on capability requirements
+.\"    A few small grammar fixes
+.\" 2010-06-13 Jan Engelhardt <jengelh@medozas.de>
+.\"    Documented SO_DOMAIN and SO_PROTOCOL.
+.\"
+.\" FIXME
+.\" The following are not yet documented:
+.\"
+.\" SO_PEERNAME (2.4?)
+.\"    get only
+.\"    Seems to do something similar to getpeername(), but then
+.\"    why is it necessary / how does it differ?
+.\"
+.\" SO_TIMESTAMPING (2.6.30)
+.\"    Documentation/networking/timestamping.txt
+.\"    commit cb9eff097831007afb30d64373f29d99825d0068
+.\"    Author: Patrick Ohly <patrick.ohly@intel.com>
+.\"
+.\"  SO_WIFI_STATUS (3.3)
+.\"    commit 6e3e939f3b1bf8534b32ad09ff199d88800835a0
+.\"    Author: Johannes Berg <johannes.berg@intel.com>
+.\"    Also: SCM_WIFI_STATUS
+.\"
+.\" SO_NOFCS (3.4)
+.\"    commit 3bdc0eba0b8b47797f4a76e377dd8360f317450f
+.\"    Author: Ben Greear <greearb@candelatech.com>
+.\"
+.\"  SO_GET_FILTER (3.8)
+.\"    commit a8fc92778080c845eaadc369a0ecf5699a03bef0
+.\"    Author: Pavel Emelyanov <xemul@parallels.com>
+.\"
+.\" SO_MAX_PACING_RATE (3.13)
+.\"    commit 62748f32d501f5d3712a7c372bbb92abc7c62bc7
+.\"    Author: Eric Dumazet <edumazet@google.com>
+.\"
+.\" SO_BPF_EXTENSIONS (3.14)
+.\"    commit ea02f9411d9faa3553ed09ce0ec9f00ceae9885e
+.\"    Author: Michal Sekletar <msekleta@redhat.com>
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
+.\" Japanese Version Copyright (c) 1999 NAKANO Takeo all rights reserved.
+.\" Translated 1999-12-06, NAKANO Takeo <nakano@apm.seikei.ac.jp>
+.\" Updated 2003-01-20, Akihiro Motoki <amotoki@dd.iij4u.or.jp>
+.\" Updated 2005-02-23, Akihiro MOTOKI
+.\" Updated 2005-10-05, Akihiro MOTOKI
+.\" Updated 2005-12-05, Akihiro MOTOKI, Catch up to LDP man-pages 2.16
+.\" Updated 2005-12-26, Akihiro MOTOKI, Catch up to LDP man-pages 2.18
+.\" Updated 2006-04-15, Akihiro MOTOKI, Catch up to LDP man-pages 2.29
+.\" Updated 2007-01-05, Akihiro MOTOKI, Catch up to LDP man-pages 2.43
+.\" Updated 2013-05-01, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-05-06, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-07-24, Akihiro MOTOKI <amotoki@gmail.com>
+.\"
+.TH SOCKET 7 2020\-08\-13 Linux "Linux Programmer's Manual"
+.SH 名前
+socket \- Linux のソケットインターフェース
+.SH 書式
+\fB#include <sys/socket.h>\fP
+.PP
+\fIsockfd\fP\fB = socket(int \fP\fIsocket_family\fP\fB, int \fP\fIsocket_type\fP\fB, int
+\fP\fIprotocol\fP\fB);\fP
+.SH 説明
+このマニュアルページは Linux ネットワークのソケット層に対する ユーザーインターフェースを記述するものである。 BSD
+互換ソケットは、ユーザープロセスとカーネル内部の ネットワークプロトコルスタック群との間に、 統一的なインターフェースを提供するものである。
+プロトコルモジュールは \fIプロトコルファミリー (protocol familiy)\fP (例: \fBAF_INET\fP, \fBAF_IPX\fP,
+\fBAF_PACKET\fP)  と \fIソケットタイプ (socket types)\fP (例: \fBSOCK_STREAM\fP,
+\fBSOCK_DGRAM\fP)  に分類できる。 これらに関するより詳しい情報は \fBsocket\fP(2)  を参照のこと。
+.SS ソケット層の関数群
+これらの関数はユーザープロセスがパケットを送受信したり、その他のソケット操作を 行ったりするために用いられる。詳細はそれぞれのマニュアルページを
+見てほしい。
+.PP
+\fBsocket\fP(2)  はソケットを生成する。 \fBconnect\fP(2)  はソケットをリモートのソケットアドレスに接続する。
+\fBbind\fP(2)  はソケットをローカルのソケットアドレスにバインドする。 \fBlisten\fP(2)
+はソケットに新しい接続が来たら受信するように伝え、 \fBaccept\fP(2)  は外部からやってきた接続に対して新しいソケットを得るために用いられる。
+\fBsocketpair\fP(2)  は互いに接続された二つの名前無しソケット (anonymous socket) を返す (\fBAF_UNIX\fP
+のような、いくつかのローカルなファミリーでしか実装されていない)。
+.PP
+\fBsend\fP(2), \fBsendto\fP(2), \fBsendmsg\fP(2)  はソケットを通してデータを送信し、 \fBrecv\fP(2)
+\fBrecvfrom\fP(2), \fBrecvmsg\fP(2)  はソケットからデータを受信する。 \fBpoll\fP(2)  と \fBselect\fP(2)
+はデータの到着を待ったり、データ送信の準備ができるまで待ったりする。 さらに、 \fBwrite\fP(2), \fBwritev\fP(2),
+\fBsendfile\fP(2), \fBread\fP(2), \fBreadv\fP(2)  のような標準的な I/O 操作もデータの読み書きに用いることができる。
+.PP
+\fBgetsockbyname\fP(2)  はローカルのソケットアドレスを返し、 \fBgetpeername\fP(2)
+はリモートのソケットアドレスを返す。 \fBgetsockopt\fP(2)  と \fBsetsockopt\fP(2)
+はソケット層のオプションやプロトコルオプションの取得・設定に用いられる。 他のいくつかのオプションの取得・設定には \fBioctl\fP(2)
+を使うことができる。
+.PP
+\fBclose\fP(2)  はソケットをクローズする。 \fBshutdown\fP(2)  は全二重なソケット接続を部分的にクローズする。
+.PP
+シーク動作や、 0 以外の位置に対する \fBpread\fP(2)  や \fBpwrite\fP(2)  はソケットではサポートされていない。
+.PP
+非ブロッキングな I/O をソケットで行うことは可能で、 \fBfcntl\fP(2)  を使ってソケットのファイルディスクリプターに
+\fBO_NONBLOCK\fP フラグをセットすれば良い。 こうするとブロックされる操作は、 (通常)  \fBEAGAIN\fP エラーで戻ることになる
+(後で処理が再試行されることが期待されている)。 \fBconnect\fP(2)  では \fBEINPROGRESS\fP エラーが返される。
+この場合、ユーザーはさまざまなイベントを \fBpoll\fP(2)  や \fBselect\fP(2)  を使って待つことができる。
+.TS
+tab(:) allbox;
+c s s
+l l l.
+I/O イベント
+イベント:poll フラグ:内容
+Read:POLLIN:T{
+新しいデータが到着した。
+T}
+Read:POLLIN:T{
+(接続志向のソケットで)
+接続の設定が終了した。
+T}
+Read:POLLHUP:T{
+接続先で切断要求が生成された。
+T}
+Read:POLLHUP:T{
+接続が壊れた (接続志向のプロトコルのみ)。
+この場合、ソケットに書き込みが行われると
+\fBSIGPIPE\fP
+も送信される。
+T}
+Write:POLLOUT:T{
+ソケットには新しいデータを書き込むのに十分なバッファーがある。
+T}
+Read/Write:T{
+POLLIN |
+.br
+POLLOUT
+T}:T{
+外部向けの
+\fBconnect\fP(2)
+が終了した。
+T}
+Read/Write:POLLERR:非同期的 (asynchronous) なエラーが起こった。
+Read/Write:POLLHUP:接続先が片方向を切断した。
+Exception:POLLPRI:T{
+緊急データ (urgent data) が到着した。この場合は
+\fBSIGURG\fP
+が送信される。
+T}
+.\" FIXME . The following is not true currently:
+.\" It is no I/O event when the connection
+.\" is broken from the local end using
+.\" .BR shutdown (2)
+.\" or
+.\" .BR close (2).
+.TE
+.PP
+\fBpoll\fP(2)  や \fBselect\fP(2)  を使う代わりに、カーネルからアプリケーションに イベントを通知させるのに \fBSIGIO\fP
+シグナルを使う方法もある。 この方法を使うには、 \fBfcntl\fP(2)  を用いてソケットのファイルディスクリプターに \fBO_ASYNC\fP
+フラグをセットし、 \fBSIGIO\fP に対する有効なシグナルハンドラーを \fBsigaction\fP(2)  によって設定しておく必要がある。 後述の
+\fIシグナル\fP に関する議論も参考にすること。
+.SS ソケットアドレス構造体
+各ソケットドメインにはそれぞれ独自のソケットアドレス形式があり、ドメイン固有のアドレス構造体を持っている。
+これらの構造体の先頭には、アドレス構造体の種類を示す整数の "family" フィールド (型は \fIsa_family_t\fP) がある。
+このフィールドにより、 すべてのソケットドメインで汎用的に使用されるシステムコール (例えば、 \fBconnect\fP(2), \fBbind\fP(2),
+\fBaccept\fP(2), \fBgetsockname\fP(2), \fBgetpeername\fP(2) など)
+が、特定のソケットアドレスのドメインを判定することができる。
+.PP
+任意の種類のソケットアドレスをソケット API のインターフェースに渡せるように、 \fIstruct sockaddr\fP 型が定義されている。
+この型の目的は、 純粋に、 ドメイン固有のソケットアドレスを 「汎用的な」型にキャストできるようにする点にある。 これにより、 ソケット API
+呼び出しにおいて、 コンパイラが型の不一致の警告を出すのを避けることができる。
+.PP
+これに加えて、ソケット API ではデータ型 \fIstruct sockaddr_storage\fP が提供されている。
+サポートしているすべてのドメイン固有のソケットアドレス構造体を収容するのに、この型を使うことができる。 この型は十分な大きさがあり、(メモリー境界への)
+アラインも適切に行われている (特に、 IPv6 ソケットアドレスを収容するのにも十分な大きさである)。 この構造体には次のフィールドがあり、
+このフィールドを使って、 この構造体に実際に格納されているソケットアドレスの型を特定することができる。
+.PP
+.in +4n
+.EX
+    sa_family_t ss_family;
+.EE
+.in
+.PP
+\fIsockaddr_storage\fP 構造体は、 ソケットアドレスを汎用的な方法で扱う必要があるプログラム (例えば、 IPv4 と IPv6
+の両方のソケットアドレスを扱う必要があるプログラム) で有用である。
+.SS ソケットオプション
+.\" FIXME .
+.\" In the list below, the text used to describe argument types
+.\" for each socket option should be more consistent
+.\"
+.\" SO_ACCEPTCONN is in POSIX.1-2001, and its origin is explained in
+.\" W R Stevens, UNPv1
+これらのソケットオプションは、 \fBsetsockopt\fP(2)  を用いれば設定でき、 \fBgetsockopt\fP(2)  を用いれば取得できる。
+但し、どのソケットの場合も ソケットレベルには \fBSOL_SOCKET\fP を指定すること。 注釈がない限り、 \fIoptval\fP は \fIint\fP
+へのポインターである。
+.TP 
+\fBSO_ACCEPTCONN\fP
+このソケットが \fBlisten\fP(2)  によって接続待ち受け状態に設定されているかどうかを示す値を返す。 値 0 は listen
+状態のソケットでないことを、 値 1 は listen 状態のソケットであることを示す。このソケットオプションは読み込み専用である。
+.TP 
+\fBSO_ATTACH_FILTER\fP (since Linux 2.2), \fBSO_ATTACH_BPF\fP (since Linux 3.19)
+Attach a classic BPF (\fBSO_ATTACH_FILTER\fP)  or an extended BPF
+(\fBSO_ATTACH_BPF\fP)  program to the socket for use as a filter of incoming
+packets.  A packet will be dropped if the filter program returns zero.  If
+the filter program returns a nonzero value which is less than the packet's
+data length, the packet will be truncated to the length returned.  If the
+value returned by the filter is greater than or equal to the packet's data
+length, the packet is allowed to proceed unmodified.
+.IP
+The argument for \fBSO_ATTACH_FILTER\fP is a \fIsock_fprog\fP structure, defined
+in \fI<linux/filter.h>\fP:
+.IP
+.in +4n
+.EX
+struct sock_fprog {
+    unsigned short      len;
+    struct sock_filter *filter;
+};
+.EE
+.in
+.IP
+The argument for \fBSO_ATTACH_BPF\fP is a file descriptor returned by the
+\fBbpf\fP(2)  system call and must refer to a program of type
+\fBBPF_PROG_TYPE_SOCKET_FILTER\fP.
+.IP
+These options may be set multiple times for a given socket, each time
+replacing the previous filter program.  The classic and extended versions
+may be called on the same socket, but the previous filter will always be
+replaced such that a socket never has more than one filter defined.
+.IP
+Both classic and extended BPF are explained in the kernel source file
+\fIDocumentation/networking/filter.txt\fP
+.TP 
+\fBSO_ATTACH_REUSEPORT_CBPF\fP, \fBSO_ATTACH_REUSEPORT_EBPF\fP
+For use with the \fBSO_REUSEPORT\fP option, these options allow the user to set
+a classic BPF (\fBSO_ATTACH_REUSEPORT_CBPF\fP)  or an extended BPF
+(\fBSO_ATTACH_REUSEPORT_EBPF\fP)  program which defines how packets are
+assigned to the sockets in the reuseport group (that is, all sockets which
+have \fBSO_REUSEPORT\fP set and are using the same local address to receive
+packets).
+.IP
+The BPF program must return an index between 0 and N\-1 representing the
+socket which should receive the packet (where N is the number of sockets in
+the group).  If the BPF program returns an invalid index, socket selection
+will fall back to the plain \fBSO_REUSEPORT\fP mechanism.
+.IP
+Sockets are numbered in the order in which they are added to the group (that
+is, the order of \fBbind\fP(2)  calls for UDP sockets or the order of
+\fBlisten\fP(2)  calls for TCP sockets).  New sockets added to a reuseport
+group will inherit the BPF program.  When a socket is removed from a
+reuseport group (via \fBclose\fP(2)), the last socket in the group will be
+moved into the closed socket's position.
+.IP
+These options may be set repeatedly at any time on any socket in the group
+to replace the current BPF program used by all sockets in the group.
+.IP
+\fBSO_ATTACH_REUSEPORT_CBPF\fP takes the same argument type as
+\fBSO_ATTACH_FILTER\fP and \fBSO_ATTACH_REUSEPORT_EBPF\fP takes the same argument
+type as \fBSO_ATTACH_BPF\fP.
+.IP
+UDP support for this feature is available since Linux 4.5; TCP support is
+available since Linux 4.6.
+.TP 
+\fBSO_BINDTODEVICE\fP
+このソケットを、引き数で渡したインターフェース名で指定される (\(lqeth0\(rq のような) 特定のデバイスにバインドする。
+名前が空文字列だったり、オプションの長さ (optlen) が 0 の場合には、 ソケットのバインドが削除される。
+渡すオプションは、インターフェース名が 入ったヌル文字で終端された可変長の文字列である。 文字列の最大のサイズは \fBIFNAMSIX\fP である。
+ソケットがインターフェースにバインドされると、 その特定のインターフェースから受信されたパケットだけを処理する。
+このオプションはいくつかのソケットタイプ、 特に \fBAF_INET\fP に対してのみ動作する点に注意すること。 パケットソケットではサポートされていない
+(通常の \fBbind\fP(2) を使うこと)。
+.IP
+Linux 3.8 より前のバージョンでは、このソケットオプションは \fBgetsockname\fP(2)
+で設定することはできたが、取得することができなかった。 Linux 3.8 以降では、読み出すことができる。 \fIoptlen\fP 引き数には、
+デバイス名を格納するのに十分なバッファーサイズを渡すべきであり、 \fBIFNAMSIZ\fP バイトにすることを推奨する。 実際のデバイス名の長さは
+\fIoptlen\fP 引き数に格納されて返される。
+.TP 
+\fBSO_BROADCAST\fP
+ブロードキャストフラグを設定・取得する。有効になっていると、データグラ
+ムソケットはブロードキャストアドレスにパケットを送信できるようになる。
+ストリーム指向のソケットには何の効果もない。
+.TP 
+\fBSO_BSDCOMPAT\fP
+BSD のバグに対して互換性を取るための機能を有効にする。 この機能は Linux 2.0 と 2.2 の UDP
+プロトコルモジュールで使用されている。 有効になっていると、 UDP ソケットで受信された ICMP エラーは ユーザープログラムに渡されない。
+これ以降のバージョンのカーネルでは、このオプションのサポートは 段階的に廃止されてきた。 Linux 2.4 ではこのオプションは黙って無視され、
+Linux 2.6 ではプログラムがこのオプションを使用すると (printk() を使って)  カーネルの警告メッセージが出力される。 Linux
+2.0 では、このオプションを指定すると、 raw ソケットにおいても BSD のバグ (ランダムヘッダー変更、 ブロードキャストフラグのスキップ)
+に対する互換機能が有効になっていた。 しかし、こちらは Linux 2.2 で削除された。
+.TP 
+\fBSO_DEBUG\fP
+ソケットのデバッグ機能を有効にする。 \fBCAP_NET_ADMIN\fP 権限を持つプロセスか、実効ユーザー ID が 0 のプロセスでしか
+利用できない。
+.TP 
+\fBSO_DETACH_FILTER\fP (Linux 2.2 以降), \fBSO_DETACH_BPF\fP (Linux 3.19 以降)
+These two options, which are synonyms, may be used to remove the classic or
+extended BPF program attached to a socket with either \fBSO_ATTACH_FILTER\fP or
+\fBSO_ATTACH_BPF\fP.  The option value is ignored.
+.TP 
+\fBSO_DOMAIN\fP (Linux 2.6.32 以降)
+ソケットドメインを整数で取得する。 \fBAF_INET6\fP のような値が返される。
+詳細は \fBsocket\fP(2) を参照。このソケットオプションは読み込み専用である。
+.TP 
+\fBSO_ERROR\fP
+保留になっていたソケットエラーを取得してクリアする。
+このソケットオプションは読み込み専用である。整数値をとる。
+.TP 
+\fBSO_DONTROUTE\fP
+ゲートウェイを経由せず、直接接続されているホストにのみ送信する。 \fBsend\fP(2)  操作で \fBMSG_DONTROUTE\fP
+フラグをセットした場合も同じ効果が得られる。 ブール整数のフラグを取る。
+.TP 
+\fBSO_INCOMING_CPU\fP (gettable since Linux 3.19, settable since Linux 4.4)
+.\" getsockopt 2c8c56e15df3d4c2af3d656e44feb18789f75837
+.\" setsockopt 70da268b569d32a9fddeea85dc18043de9d89f89
+Sets or gets the CPU affinity of a socket.  Expects an integer flag.
+.IP
+.in +4n
+.EX
+int cpu = 1;
+setsockopt(fd, SOL_SOCKET, SO_INCOMING_CPU, &cpu,
+           sizeof(cpu));
+.EE
+.in
+.IP
+.\"
+.\" From an email conversation with Eric Dumazet:
+.\" >> Note that setting the option is not supported if SO_REUSEPORT is used.
+.\" >
+.\" > Please define "not supported". Does this yield an API diagnostic?
+.\" > If so, what is it?
+.\" >
+.\" >> Socket will be selected from an array, either by a hash or BPF program
+.\" >> that has no access to this information.
+.\" >
+.\" > Sorry -- I'm lost here. How does this comment relate to the proposed
+.\" > man page text above?
+.\"
+.\" Simply that :
+.\"
+.\" If an application uses both SO_INCOMING_CPU and SO_REUSEPORT, then
+.\" SO_REUSEPORT logic, selecting the socket to receive the packet, ignores
+.\" SO_INCOMING_CPU setting.
+Because all of the packets for a single stream (i.e., all packets for the
+same 4\-tuple)  arrive on the single RX queue that is associated with a
+particular CPU, the typical use case is to employ one listening process per
+RX queue, with the incoming flow being handled by a listener on the same CPU
+that is handling the RX queue.  This provides optimal NUMA behavior and
+keeps CPU caches hot.
+.TP 
+\fBSO_INCOMING_NAPI_ID\fP (gettable since Linux 4.12)
+.\" getsockopt 6d4339028b350efbf87c61e6d9e113e5373545c9
+Returns a system\-level unique ID called NAPI ID that is associated with a RX
+queue on which the last packet associated with that socket is received.
+.IP
+This can be used by an application to split the incoming flows among worker
+threads based on the RX queue on which the packets associated with the flows
+are received.  It allows each worker thread to be associated with a NIC HW
+receive queue and service all the connection requests received on that RX
+queue.  This mapping between a app thread and a HW NIC queue streamlines the
+flow of data from the NIC to the application.
+.TP 
+\fBSO_KEEPALIVE\fP
+接続志向のソケットに対する keep\-alive メッセージの送信を有効にする。 ブール値の整数フラグをとる。
+.TP 
+\fBSO_LINGER\fP
+\fBSO_LINGER\fP オプションを取得・設定する。引き数には \fIlinger\fP 構造体を取る。
+.IP
+.in +4n
+.EX
+struct linger {
+    int l_onoff;    /* linger active */
+    int l_linger;   /* how many seconds to linger for */
+};
+.EE
+.in
+.IP
+有効になっていると、 \fBclose\fP(2)  や \fBshutdown\fP(2)
+は、そのソケットにキューイングされたメッセージがすべて送信完了するか、 linger (居残り) タイムアウトになるまで返らない。無効になっていると、
+これらのコールはただちに戻り、クローズ動作はバックグラウンドで行われる。 ソケットのクローズを \fBexit\fP(2)
+の一部として行った場合には、残っているソケットの クローズ動作は必ずバックグラウンドに送られる。
+.TP 
+\fBSO_LOCK_FILTER\fP
+.\" commit d59577b6ffd313d0ab3be39cb1ab47e29bdc9182
+When set, this option will prevent changing the filters associated with the
+socket.  These filters include any set using the socket options
+\fBSO_ATTACH_FILTER\fP, \fBSO_ATTACH_BPF\fP, \fBSO_ATTACH_REUSEPORT_CBPF\fP, and
+\fBSO_ATTACH_REUSEPORT_EBPF\fP.
+.IP
+The typical use case is for a privileged process to set up a raw socket (an
+operation that requires the \fBCAP_NET_RAW\fP capability), apply a restrictive
+filter, set the \fBSO_LOCK_FILTER\fP option, and then either drop its
+privileges or pass the socket file descriptor to an unprivileged process via
+a UNIX domain socket.
+.IP
+Once the \fBSO_LOCK_FILTER\fP option has been enabled, attempts to change or
+remove the filter attached to a socket, or to disable the \fBSO_LOCK_FILTER\fP
+option will fail with the error \fBEPERM\fP.
+.TP 
+\fBSO_MARK\fP (Linux 2.6.25 以降)
+.\" commit 4a19ec5800fc3bb64e2d87c4d9fdd9e636086fe0
+.\" and    914a9ab386a288d0f22252fc268ecbc048cdcbd5
+このソケットから送信される各パケットにマークをセットする (netfilter の MARK ターゲットと似ているが、ソケット単位である点が異なる)。
+マークの変更は、 netfilter なしでのマークに基づいてのルーティングや、 パケットフィルタリングに使うことができる。
+このオプションを変更するには \fBCAP_NET_ADMIN\fP ケーパビリティが必要である。
+.TP 
+\fBSO_OOBINLINE\fP
+.\" don't document it because it can do too much harm.
+.\".B SO_NO_CHECK
+.\"     The kernel has support for the SO_NO_CHECK socket
+.\"     option (boolean: 0 == default, calculate checksum on xmit,
+.\"     1 == do not calculate checksum on xmit).
+.\" Additional note from Andi Kleen on SO_NO_CHECK (2010-08-30)
+.\"     On Linux UDP checksums are essentially free and there's no reason
+.\"     to turn them off and it would disable another safety line.
+.\"     That is why I didn't document the option.
+このオプションを有効にすると、帯域外データ (out\-of\-band data) は 受信データストリーム中に置かれる。有効にしなければ、
+帯域外データは受信時に \fBMSG_OOB\fP フラグがセットされている場合に限って渡される。
+.TP 
+\fBSO_PASSCRED\fP
+\fBSCM_CREDENTIALS\fP 制御メッセージの受信を有効/無効にする。詳細は \fBunix\fP(7)  を参照のこと。
+.TP 
+\fBSO_PASSSEC\fP
+\fBSCM_SECURITY\fP 制御メッセージの受信を有効/無効にする。詳細は \fBunix\fP(7)  を参照のこと。
+.TP 
+\fBSO_PEEK_OFF\fP (Linux 3.4 以降)
+.\" commit ef64a54f6e558155b4f149bb10666b9e914b6c54
+\fBMSG_PEEK\fP フラグと一緒に使用された場合 \fBrecv\fP(2) システムコールの "peek offset"
+にこのオプションの値が設定される。現在のところ、このオプションは \fBunix\fP(7) ソケットでのみサポートされている。
+.IP
+このオプションが負の値に設定された場合、従来の動作となる。 つまり \fBMSG_PEEK\fP フラグが指定された \fBrecv\fP(2)
+は、キューの先頭のデータに対して peek 処理を行う (データを読み出すが、キューからデータの削除を行わない)。
+新規のソケットではこのオプションの値は必ず \-1 に設定される。
+.IP
+このオプションに 0 以上の値が設定されると、 そのソケットのキュー上のオプション値で指定されたバイトオフセットにあるデータが次の peek
+処理で返される。 同時に、 "peek offset" がキューから peek 処理されたバイト数だけ加算される。したがって、次の peek
+処理ではキューのその次にあるデータが返される。
+.IP
+\fBrecv\fP(2) (や同様のシステムコール) の \fBMSG_PEEK\fP フラグなしの呼び出しでキューの先頭のデータが削除された場合、 "peek
+offset" は削除されたバイト数だけ減算される。 言い換えると、 \fBMSG_PEEK\fP フラグなしでデータを受信すると、 "peek
+offset" が指すキュー内の相対的な位置が狂わないように調整され、この後の peek では、
+データ削除が行われなかった場合に返されたのと同じ値が返されるということである。
+.IP
+データグラムソケットでは、 "peek offset" がパケットの途中を指している場合には、 返されるデータには \fBMSG_TRUNC\fP
+フラグが付与される。
+.IP
+以下の例は \fBSO_PEEK_OFF\fP の利用例を示している。ストリームソケットのキューに以下の入力データが入っているものとする。
+.IP
+    aabbccddeeff
+.IP
+以下の順序で \fBrecv\fP(2) の呼び出しを行うと、コメントに書かれた結果となる。
+.IP
+.in +4n
+.EX
+int ov = 4;                  // Set peek offset to 4
+setsockopt(fd, SOL_SOCKET, SO_PEEK_OFF, &ov, sizeof(ov));
+
+recv(fd, buf, 2, MSG_PEEK);  // Peeks "cc"; offset set to 6
+recv(fd, buf, 2, MSG_PEEK);  // Peeks "dd"; offset set to 8
+recv(fd, buf, 2, 0);         // Reads "aa"; offset set to 6
+recv(fd, buf, 2, MSG_PEEK);  // Peeks "ee"; offset set to 8
+.EE
+.in
+.TP 
+\fBSO_PEERCRED\fP
+Return the credentials of the peer process connected to this socket.  For
+further details, see \fBunix\fP(7).
+.TP 
+\fBSO_PEERSEC\fP (Linux 2.6.2 以降)
+Return the security context of the peer socket connected to this socket.
+For further details, see \fBunix\fP(7)  and \fBip\fP(7).
+.TP 
+\fBSO_PRIORITY\fP
+.\" For
+.\" .BR ip (7),
+.\" this also sets the IP type-of-service (TOS) field for outgoing packets.
+プロトコルで定義された優先度を、このソケットから 送信される全てのパケットにセットする。 Linux はネットワークキュー内部の
+整列にこの値を用いる。高い優先度を持っているパケットは先に処理される。 ただしそのデバイスのキュー処理のやり方に依存する。 0 から 6
+以外の優先度をセットするには \fBCAP_NET_ADMIN\fP ケーパビリティが必要である。
+.TP 
+\fBSO_PROTOCOL\fP (Linux 2.6.32 以降)
+ソケットのプロトコルを整数で取得する。 \fBIPPROTO_SCTP\fP のような値が返される。
+詳細は \fBsocket\fP(2) を参照。このソケットオプションは読み込み専用である。
+.TP 
+\fBSO_RCVBUF\fP
+.\" Most (all?) other implementations do not do this -- MTK, Dec 05
+.\" The following thread on LMKL is quite informative:
+.\" getsockopt/setsockopt with SO_RCVBUF and SO_SNDBUF "non-standard" behavior
+.\" 17 July 2012
+.\" http://thread.gmane.org/gmane.linux.kernel/1328935
+ソケットの受信バッファーの最大サイズを設定・取得する (バイト単位)。 \fBsetsockopt\fP(2)  を使って値が設定されたときに
+(管理オーバヘッド用の領域を確保するために)  カーネルはこの値を 2倍し、 \fBgetsockopt\fP(2)  はこの 2倍された値を返す。
+デフォルトの値は \fI/proc/sys/net/core/rmem_default\fP ファイルで設定され、許容される最大の値は
+\fI/proc/sys/net/core/rmem_max\fP ファイルで設定される。 このオプションの最小値は (2倍した値で) 256 である。
+.TP 
+\fBSO_RCVBUFFORCE\fP (Linux 2.6.14 以降)
+このソケットオプションを使うと、特権プロセス (\fBCAP_NET_ADMIN\fP を持つプロセス) は \fBSO_RCVBUF\fP
+と同じことを実行できる。 ただし、上限 \fIrmem_max\fP を上書きすることができる。
+.TP 
+\fBSO_RCVLOWAT\fP と \fBSO_SNDLOWAT\fP
+Specify the minimum number of bytes in the buffer until the socket layer
+will pass the data to the protocol (\fBSO_SNDLOWAT\fP)  or the user on
+receiving (\fBSO_RCVLOWAT\fP).  These two values are initialized to 1.
+\fBSO_SNDLOWAT\fP is not changeable on Linux (\fBsetsockopt\fP(2)  fails with the
+error \fBENOPROTOOPT\fP).  \fBSO_RCVLOWAT\fP is changeable only since Linux 2.4.
+.IP
+.\" Tested on kernel 2.6.14 -- mtk, 30 Nov 05
+.\" commit c7004482e8dcb7c3c72666395cfa98a216a4fb70
+Before Linux 2.6.28 \fBselect\fP(2), \fBpoll\fP(2), and \fBepoll\fP(7)  did not
+respect the \fBSO_RCVLOWAT\fP setting on Linux, and indicated a socket as
+readable when even a single byte of data was available.  A subsequent read
+from the socket would then block until \fBSO_RCVLOWAT\fP bytes are available.
+Since Linux 2.6.28, \fBselect\fP(2), \fBpoll\fP(2), and \fBepoll\fP(7)  indicate a
+socket as readable only if at least \fBSO_RCVLOWAT\fP bytes are available.
+.TP 
+\fBSO_RCVTIMEO\fP と \fBSO_SNDTIMEO\fP
+.\" Not implemented in 2.0.
+.\" Implemented in 2.1.11 for getsockopt: always return a zero struct.
+.\" Implemented in 2.3.41 for setsockopt, and actually used.
+.\" in fact to EAGAIN
+送信・受信のタイムアウトを指定する。これを越えるとエラーを報告する。 引き数は \fIstruct timeval\fP である。
+入出力関数がタイムアウト時間の間ブロックされ、かつデータの送信または 受信が行われていた場合は、転送されたデータ量が関数の返り値となる。
+何もデータが転送されずにタイムアウトに達した場合は、 \-1 を返し、 \fIerrno\fP に \fBEAGAIN\fP か \fBEWOULDBLOCK\fP か
+\fBEINPROGRESS\fP (\fBconnect\fP(2) の場合) が設定され、 あたかもソケットに非ブロッキングが指定されたように見える。
+タイムアウト値に (デフォルト値である) 0 に設定すると、 操作は決してタイムアウトしなくなる。 タイムアウトが影響を及ぼすのは、 ソケット I/O
+を実行するシステムコールだけ (例えば \fBread\fP(2), \fBrecvmsg\fP(2), \fBsend\fP(2), \fBsendmsg\fP(2))
+である。 \fBselect\fP(2), \fBpoll\fP(2), \fBepoll_wait\fP(2)  などにはタイムアウトは影響を及ぼさない。
+.TP 
+\fBSO_REUSEADDR\fP
+.\"    commit c617f398edd4db2b8567a28e899a88f8f574798d
+.\"    https://lwn.net/Articles/542629/
+\fBbind\fP(2)  コールに与えられたアドレスが正しいかを判断するルールで、 ローカルアドレスの再利用を可能にする。 つまり \fBAF_INET\fP
+ソケットなら、そのアドレスにバインドされたアクティブな listen 状態のソケットが存在しない限り、バインドが行える。 listen
+状態のソケットがアドレス \fBINADDR_ANY\fP で特定のポートにバインドされている場合には、
+このポートに対しては、どんなローカルアドレスでもバインドできない。 引き数はブール整数のフラグである。
+.TP 
+\fBSO_REUSEPORT\fP (Linux 3.9 以降)
+Permits multiple \fBAF_INET\fP or \fBAF_INET6\fP sockets to be bound to an
+identical socket address.  This option must be set on each socket (including
+the first socket)  prior to calling \fBbind\fP(2)  on the socket.  To prevent
+port hijacking, all of the processes binding to the same address must have
+the same effective UID.  This option can be employed with both TCP and UDP
+sockets.
+.IP
+For TCP sockets, this option allows \fBaccept\fP(2)  load distribution in a
+multi\-threaded server to be improved by using a distinct listener socket for
+each thread.  This provides improved load distribution as compared to
+traditional techniques such using a single \fBaccept\fP(2)ing thread that
+distributes connections, or having multiple threads that compete to
+\fBaccept\fP(2)  from the same socket.
+.IP
+For UDP sockets, the use of this option can provide better distribution of
+incoming datagrams to multiple processes (or threads) as compared to the
+traditional technique of having multiple processes compete to receive
+datagrams on the same socket.
+.TP 
+\fBSO_RXQ_OVFL\fP (Linux 2.6.33 以降)
+.\" commit 3b885787ea4112eaa80945999ea0901bf742707f
+Indicates that an unsigned 32\-bit value ancillary message (cmsg)  should be
+attached to received skbs indicating the number of packets dropped by the
+socket since its creation.
+.TP 
+\fBSO_SELECT_ERR_QUEUE\fP (Linux 3.10 以降)
+.\"    commit 7d4c04fc170087119727119074e72445f2bb192b
+.\"    Author: Keller, Jacob E <jacob.e.keller@intel.com>
+.\" It does not affect wake up.
+When this option is set on a socket, an error condition on a socket causes
+notification not only via the \fIexceptfds\fP set of \fBselect\fP(2).  Similarly,
+\fBpoll\fP(2)  also returns a \fBPOLLPRI\fP whenever an \fBPOLLERR\fP event is
+returned.
+.IP
+.\" commit 6e5d58fdc9bedd0255a8
+.\" ("skbuff: Fix not waking applications when errors are enqueued")
+Background: this option was added when waking up on an error condition
+occurred only via the \fIreadfds\fP and \fIwritefds\fP sets of \fBselect\fP(2).  The
+option was added to allow monitoring for error conditions via the
+\fIexceptfds\fP argument without simultaneously having to receive notifications
+(via \fIreadfds\fP)  for regular data that can be read from the socket.  After
+changes in Linux 4.16, the use of this flag to achieve the desired
+notifications is no longer necessary.  This option is nevertheless retained
+for backwards compatibility.
+.TP 
+\fBSO_SNDBUF\fP
+.\" Most (all?) other implementations do not do this -- MTK, Dec 05
+.\" See also the comment to SO_RCVBUF (17 Jul 2012 LKML mail)
+ソケットの送信バッファーの最大サイズを設定・取得する (バイト単位)。 \fBsetsockopt\fP(2)  を使って値が設定されたときに
+(管理オーバヘッド用の領域を確保するために)  カーネルはこの値を 2倍し、 \fBgetsockopt\fP(2)  はこの 2倍された値を返す。
+デフォルトの値は \fI/proc/sys/net/core/wmem_default\fP ファイルで設定され、許容される最大の値は
+\fI/proc/sys/net/core/wmem_max\fP ファイルで設定される。 このオプションの最小値は (2倍した値で) 2048 である。
+.TP 
+\fBSO_SNDBUFFORCE\fP (Linux 2.6.14 以降)
+このソケットオプションを使うと、特権プロセス (\fBCAP_NET_ADMIN\fP を持つプロセス) は \fBSO_SNDBUF\fP
+と同じことを実行できる。 ただし、上限 \fIwmem_max\fP を上書きすることができる。
+.TP 
+\fBSO_TIMESTAMP\fP
+Enable or disable the receiving of the \fBSO_TIMESTAMP\fP control message.  The
+timestamp control message is sent with level \fBSOL_SOCKET\fP and a
+\fIcmsg_type\fP of \fBSCM_TIMESTAMP\fP.  The \fIcmsg_data\fP field is a \fIstruct
+timeval\fP indicating the reception time of the last packet passed to the user
+in this call.  See \fBcmsg\fP(3)  for details on control messages.
+.TP 
+\fBSO_TIMESTAMPNS\fP (Linux 2.6.22 以降)
+.\" commit 92f37fd2ee805aa77925c1e64fd56088b46094fc
+Enable or disable the receiving of the \fBSO_TIMESTAMPNS\fP control message.
+The timestamp control message is sent with level \fBSOL_SOCKET\fP and a
+\fIcmsg_type\fP of \fBSCM_TIMESTAMPNS\fP.  The \fIcmsg_data\fP field is a \fIstruct
+timespec\fP indicating the reception time of the last packet passed to the
+user in this call.  The clock used for the timestamp is \fBCLOCK_REALTIME\fP.
+See \fBcmsg\fP(3)  for details on control messages.
+.IP
+A socket cannot mix \fBSO_TIMESTAMP\fP and \fBSO_TIMESTAMPNS\fP: the two modes are
+mutually exclusive.
+.TP 
+\fBSO_TYPE\fP
+ソケットのタイプを整数で取得する (例: \fBSOCK_STREAM\fP)。
+このソケットオプションは読み出し専用である。
+.TP 
+\fBSO_BUSY_POLL\fP (Linux 3.11 以降)
+データがなかった際にブロッキング受信での busy polling のおおよその時間をマイクロ秒単位で設定する。 この値を増やすには
+\fBCAP_NET_ADMIN\fP ケーパビリティが必要である。 このオプションのデフォルト値は
+\fI/proc/sys/net/core/busy_read\fP で制御できる。
+.IP
+\fI/proc/sys/net/core/busy_poll\fP の値により、 \fBSO_BUSY_POLL\fP がセットされたソケットに対して
+\fBselect\fP(2) や \fBpoll\fP(2) を行い、報告すべきイベントがない場合に、 \fBselect\fP(2) や \fBpoll\fP(2) が
+busy polling をどのくらいの時間行うかが決まる。
+.IP
+どちらの場合も、busy polling は、そのソケットが最後にデータを受信したネットワークデバイスがこのオプションに対応している場合のみ行われる。
+.IP
+busy polling により遅延が改善されるはアプリケーションもあるが、 busy polling は CPU
+使用率と電力使用量をともに増加させることになるので、使用する際は注意して行うこと。
+.SS シグナル
+(ローカルもしくはリモート側で) 切断された 接続指向 (connection\-oriented) のソケットに対して
+書き込みを行うと、その書き込みを行ったプロセスに \fBSIGPIPE\fP が送られ、 \fBEPIPE\fP が返される。 write 呼び出しに
+\fBMSG_NOSIGNAL\fP フラグを指定していた場合はシグナルは送られない。
+.PP
+\fBFIOSETOWN\fP \fBfcntl\fP(2)  や \fBSIOCSPGRP\fP \fBioctl\fP(2)
+をプロセスまたはプロセスグループに指定しておくと、 I/O イベントが起きたときに \fBSIGIO\fP が送られる。 \fBpoll\fP(2)  や
+\fBselect\fP(2)  をシグナルハンドラー内で用いれば、どのソケットでイベントが起こったかを 知ることができる。 (Linux 2.2 における)
+別の方法としては、 \fBF_SETSIG\fP \fBfcntl\fP(2)  を用いてリアルタイムシグナルを設定するやり方もある。
+リアルタイムシグナルのハンドラーは、 \fIsiginfo_t\fP の \fIsi_fd\fP フィールドにファイルディスクリプターが入った状態で呼び出される。
+詳細は \fBfcntl\fP(2)  を参照のこと。
+.PP
+.\" .SS Ancillary messages
+状況によっては (例えば複数のプロセスが一つのソケットにアクセスしているなど)、 \fBSIGIO\fP
+の原因となった状態は、プロセスがそのシグナルへの対応を行ったときには 消えてしまっているかもしれない。
+この場合は、プロセスは再び待つようにすべきである。 Linux は同じシグナルを後で再送するからである。
+.SS "/proc インターフェース"
+core のソケットのネットワーキングパラメーターには、 \fI/proc/sys/net/core/\fP ディレクトリ内のファイルを通してアクセスできる。
+.TP 
+\fIrmem_default\fP
+ソケットの受信バッファーサイズのデフォルト値 (バイト単位)。
+.TP 
+\fIrmem_max\fP
+\fBSO_RCVBUF\fP ソケットオプションを用いてユーザーが設定できる ソケットの受信バッファーサイズの最大値 (バイト単位)。
+.TP 
+\fIwmem_default\fP
+ソケットの送信バッファーサイズのデフォルト値 (バイト単位)。
+.TP 
+\fIwmem_max\fP
+\fBSO_SNDBUF\fP ソケットオプションを用いてユーザーが設定できる ソケットの送信バッファーサイズの最大値 (バイト単位)。
+.TP 
+\fImessage_cost\fP と \fImessage_burst\fP
+トークンバケットフィルターを設定する。 これは外部のネットワークイベントによって引き起こされた 負荷限界の警告メッセージに用いられる。
+.TP 
+\fInetdev_max_backlog\fP
+グローバルな入力キューにおける最大のパケット数。
+.TP 
+\fIoptmem_max\fP
+.\" netdev_fastroute is not documented because it is experimental
+ソケットあたりの、補助データ (ancillary data) とユーザー制御データ (iovecs のようなもの) との和の最大長。
+.SS ioctl
+以下に示す操作には \fBioctl\fP(2)  を用いてアクセスできる。
+.PP
+.in +4n
+.EX
+\fIerror\fP\fB = ioctl(\fP\fIip_socket\fP\fB, \fP\fIioctl_type\fP\fB, \fP\fI&value_result\fP\fB);\fP
+.EE
+.in
+.TP 
+\fBSIOCGSTAMP\fP
+.\"
+Return a \fIstruct timeval\fP with the receive timestamp of the last packet
+passed to the user.  This is useful for accurate round trip time
+measurements.  See \fBsetitimer\fP(2)  for a description of \fIstruct timeval\fP.
+This ioctl should be used only if the socket options \fBSO_TIMESTAMP\fP and
+\fBSO_TIMESTAMPNS\fP are not set on the socket.  Otherwise, it returns the
+timestamp of the last packet that was received while \fBSO_TIMESTAMP\fP and
+\fBSO_TIMESTAMPNS\fP were not set, or it fails if no such packet has been
+received, (i.e., \fBioctl\fP(2)  returns \-1 with \fIerrno\fP set to \fBENOENT\fP).
+.TP 
+\fBSIOCSPGRP\fP
+Set the process or process group that is to receive \fBSIGIO\fP or \fBSIGURG\fP
+signals when I/O becomes possible or urgent data is available.  The argument
+is a pointer to a \fIpid_t\fP.  For further details, see the description of
+\fBF_SETOWN\fP in \fBfcntl\fP(2).
+.TP 
+\fBFIOASYNC\fP
+\fBO_ASYNC\fP フラグを変更し、ソケットの非同期 (asynchronous) I/O モードを 有効/無効にする。非同期 I/O モードでは、
+新しい I/O イベントが起きたときに、 \fBSIGIO\fP シグナルや \fBF_SETSIG\fP で設定されたシグナルセットが発行される。
+.IP
+.\"
+引き数はブール整数のフラグである。 (この操作は \fBfcntl\fP(2)  を使って \fBO_ASYNC\fP フラグをセットするのと同じ意味である。)
+.TP 
+\fBSIOCGPGRP\fP
+\fBSIGIO\fP や \fBSIGURG\fP を受信したカレントプロセスかプロセスグループを取得する。 ない場合は 0 が返る。
+.PP
+有効な \fBfcntl\fP(2)  操作:
+.TP 
+\fBFIOGETOWN\fP
+\fBSIOCGPGRP\fP \fBioctl\fP(2)  と同じ。
+.TP 
+\fBFIOSETOWN\fP
+\fBSIOCSPGRP\fP \fBioctl\fP(2)  と同じ。
+.SH バージョン
+\fBSO_BINDTODEVICE\fP は Linux 2.0.30 で導入された。 \fBSO_PASSCRED\fP は Linux 2.2 で登場した。
+\fI/proc\fP インターフェースは Linux 2.2 で導入された。 \fBSO_RCVTIMEO\fP と \fBSO_SNDTIMEO\fP は Linux
+2.3.41 以降でサポートされている。 それ以前は、タイムアウトはプロトコル固有の固定の設定値で、 読み書きをすることはできなかった。
+.SH 注意
+Linux は、送受信バッファーの半分を内部のカーネル構造体で用いると仮定している。 したがって、対応する \fI/proc\fP
+ファイルはネットワーク回線上での大きさの 2 倍になる。
+.PP
+.\" .SH AUTHORS
+.\" This man page was written by Andi Kleen.
+Linux では、 \fBSO_REUSEADDR\fP オプションでポートの再利用が許可されるのは、 そのポートに対して \fBbind\fP(2)
+を前に実行したプログラムとそのポートを再利用 しようとするプログラムの両方で \fBSO_REUSEADDR\fP がセットされた場合のみである。 この動作は
+(FreeBSD などの) いくつかの実装とは異なる。これらでは、 後でポートを再利用しようとするプログラムで \fBSO_REUSEADDR\fP
+オプションをセットするだけでよい。 たいていはこの違いは見えない。なぜなら、例えばサーバプログラムは
+常にこのオプションをセットするように設計されるからである。
+.SH 関連項目
+\fBwireshark\fP(1), \fBbpf\fP(2), \fBconnect\fP(2), \fBgetsockopt\fP(2),
+\fBsetsockopt\fP(2), \fBsocket\fP(2), \fBpcap\fP(3), \fBaddress_families\fP(7),
+\fBcapabilities\fP(7), \fBddp\fP(7), \fBip\fP(7), \fBipv6\fP(7), \fBpacket\fP(7),
+\fBtcp\fP(7), \fBudp\fP(7), \fBunix\fP(7), \fBtcpdump\fP(8)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
+\%https://www.kernel.org/doc/man\-pages/ に書かれている。