OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / draft / man2 / select_tut.2
index 4c6e702..808ad8d 100644 (file)
@@ -1,5 +1,6 @@
 .\" 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.
@@ -19,6 +20,7 @@
 .\"
 .\" 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
 .\"
 .\"             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
 .\"
-.\"WORD:       file descriptor         ファイルディスクリプタ
-.\"WORD:       exceptional condition   例外状態
-.\"
-.TH SELECT_TUT 2 2010-06-10 "Linux" "Linux Programmer's Manual"
-.\"O .SH NAME
+.TH SELECT_TUT 2 2013\-12\-30 Linux "Linux Programmer's Manual"
 .SH 名前
-.\"O select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO \-
-.\"O synchronous I/O multiplexing
 select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO \- 同期 I/O の多重化
-.\"O .SH SYNOPSIS
 .SH 書式
 .nf
-.\"O /* According to POSIX.1-2001 */
-/* POSIX.1-2001 に従う場合 */
+/* POSIX.1\-2001 に従う場合 */
 .br
-.B #include <sys/select.h>
+\fB#include <sys/select.h>\fP
 .sp
-.\"O /* According to earlier standards */
 /* 以前の規格に従う場合 */
 .br
-.B #include <sys/time.h>
+\fB#include <sys/time.h>\fP
 .br
-.B #include <sys/types.h>
+\fB#include <sys/types.h>\fP
 .br
-.B #include <unistd.h>
+\fB#include <unistd.h>\fP
 .sp
-.BI "int select(int " nfds ", fd_set *" readfds ", fd_set *" writefds ,
-.BI "           fd_set *" exceptfds ", struct timeval *" utimeout );
+\fBint select(int \fP\fInfds\fP\fB, fd_set *\fP\fIreadfds\fP\fB, fd_set *\fP\fIwritefds\fP\fB,\fP
+\fB           fd_set *\fP\fIexceptfds\fP\fB, struct timeval *\fP\fIutimeout\fP\fB);\fP
 .sp
-.BI "void FD_CLR(int " fd ", fd_set *" set );
+\fBvoid FD_CLR(int \fP\fIfd\fP\fB, fd_set *\fP\fIset\fP\fB);\fP
 .br
-.BI "int  FD_ISSET(int " fd ", fd_set *" set );
+\fBint  FD_ISSET(int \fP\fIfd\fP\fB, fd_set *\fP\fIset\fP\fB);\fP
 .br
-.BI "void FD_SET(int " fd ", fd_set *" set );
+\fBvoid FD_SET(int \fP\fIfd\fP\fB, fd_set *\fP\fIset\fP\fB);\fP
 .br
-.BI "void FD_ZERO(fd_set *" set );
+\fBvoid FD_ZERO(fd_set *\fP\fIset\fP\fB);\fP
 .sp
-.B #include <sys/select.h>
+\fB#include <sys/select.h>\fP
 .sp
-.BI "int pselect(int " nfds ", fd_set *" readfds ", fd_set *" writefds ,
-.BI "            fd_set *" exceptfds ", const struct timespec *" ntimeout ,
-.BI "            const sigset_t *" sigmask );
+\fBint pselect(int \fP\fInfds\fP\fB, fd_set *\fP\fIreadfds\fP\fB, fd_set *\fP\fIwritefds\fP\fB,\fP
+\fB            fd_set *\fP\fIexceptfds\fP\fB, const struct timespec *\fP\fIntimeout\fP\fB,\fP
+\fB            const sigset_t *\fP\fIsigmask\fP\fB);\fP
 .fi
 .sp
 .in -4n
-.\"O Feature Test Macro Requirements for glibc (see
-.\"O .BR feature_test_macros (7)):
-glibc 向けの機能検査マクロの要件
-.RB ( feature_test_macros (7)
-参照):
+glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
 .in
 .sp
-.BR pselect ():
-_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
-.\"O .SH DESCRIPTION
+\fBpselect\fP(): _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
 .SH 説明
-.\"O .BR select ()
-.\"O (or
-.\"O .BR pselect ())
-.\"O is used to efficiently monitor multiple file descriptors,
-.\"O to see if any of them is, or becomes, "ready";
-.\"O that is, to see whether I/O becomes possible,
-.\"O or an "exceptional condition" has occurred on any of the descriptors.
-.BR select ()
-(や
-.BR pselect ())
-を使うと、効率的に複数のファイルディスクリプタを監視し、
-そのファイルディスクリプタのいずれかが
-「ready (準備ができた)」状態、つまり I/O (入出力) が可能になっているかや、
-ファイルディスクリプタのいずれかが
-「例外状態 (exceptional condition)」が発生したか、を調べることができる。
-
-.\"O Its principal arguments are three "sets" of file descriptors:
-.\"O \fIreadfds\fP, \fIwritefds\fP, and \fIexceptfds\fP.
-この関数の主要な引き数は、3種類のファイルディスクリプタの「集合」
-\fIreadfds\fP, \fIwritefds\fP, \fIexceptfds\fP である。
-.\"O Each set is declared as type
-.\"O .IR fd_set ,
-.\"O and its contents can be manipulated with the macros
-.\"O .BR FD_CLR (),
-.\"O .BR FD_ISSET (),
-.\"O .BR FD_SET (),
-.\"O and
-.\"O .BR FD_ZERO ().
-.\"O A newly declared set should first be cleared using
-.\"O .BR FD_ZERO ().
-各々の集合は
-.B fd_set
-として宣言され、その内容は
-.BR FD_CLR (),
-.BR FD_ISSET (),
-.BR FD_SET (),
-.BR FD_ZERO ()
-といったマクロによって操作できる。
-新しく宣言された集合は、まず最初に
-.BR FD_ZERO ()
-を使ってクリアすべきである。
-.\"O .BR select ()
-.\"O modifies the contents of the sets according to the rules
-.\"O described below; after calling
-.\"O .BR select ()
-.\"O you can test if a file descriptor is still present in a set with the
-.\"O .BR FD_ISSET ()
-.\"O macro.
-.\"O .BR FD_ISSET ()
-.\"O returns nonzero if a specified file descriptor is present in a set
-.\"O and zero if it is not.
-.\"O .BR FD_CLR ()
-.\"O removes a file descriptor from a set.
-.BR select ()
-はこれらの集合の内容を、以降に述べる規則に従って修正する。
-.BR select ()
-を呼んだ後、ファイルディスクリプタがまだ集合に存在しているかどうかは、
-.BR FD_ISSET ()
-マクロによって調べることができる。
-.BR FD_ISSET ()
-は指定されたディスクリプタが集合に存在していれば 0 以外の値を返し、
-存在しなければ 0 を返す。
-.BR FD_CLR ()
-は集合からのファイルディスクリプタの削除を行う。
-.\"O .SS Arguments
+\fBselect\fP()  (や \fBpselect\fP())  を使うと、効率的に複数のファイルディスクリプターを監視し、
+そのファイルディスクリプターのいずれかが 「ready (準備ができた)」状態、つまり I/O (入出力) が可能になっているかや、
+ファイルディスクリプターのいずれかが 「例外状態 (exceptional condition)」が発生したか、を調べることができる。
+
+この関数の主要な引き数は、3種類のファイルディスクリプターの「集合」 \fIreadfds\fP, \fIwritefds\fP, \fIexceptfds\fP
+である。 各々の集合は \fBfd_set\fP として宣言され、その内容は \fBFD_CLR\fP(), \fBFD_ISSET\fP(), \fBFD_SET\fP(),
+\fBFD_ZERO\fP()  といったマクロによって操作できる。 新しく宣言された集合は、まず最初に \fBFD_ZERO\fP()
+を使ってクリアすべきである。 \fBselect\fP()  はこれらの集合の内容を、以降に述べる規則に従って修正する。 \fBselect\fP()
+を呼んだ後、ファイルディスクリプターがまだ集合に存在しているかどうかは、 \fBFD_ISSET\fP()  マクロによって調べることができる。
+\fBFD_ISSET\fP()  は指定されたディスクリプターが集合に存在していれば 0 以外の値を返し、 存在しなければ 0 を返す。
+\fBFD_CLR\fP()  は集合からのファイルディスクリプターの削除を行う。
 .SS 引き数
-.TP
+.TP 
 \fIreadfds\fP
-.\"O This set is watched to see if data is available for reading from any of
-.\"O its file descriptors.
-.\"O After
-.\"O .BR select ()
-.\"O has returned, \fIreadfds\fP will be
-.\"O cleared of all file descriptors except for those that
-.\"O are immediately available for reading.
-この集合に含まれるいずれかのファイルディスクリプタで、
-データの読み込みが可能になったかどうかを監視する。
-.BR select ()
-から戻る時に、\fIreadfds\fP のうち、
-直ちに読み込み可能なファイルディスクリプタ以外は
-集合から削除される。
-.TP
+この集合に含まれるいずれかのファイルディスクリプターで、 データの読み込みが可能になったかどうかを監視する。 \fBselect\fP()
+から戻る時に、\fIreadfds\fP のうち、 直ちに読み込み可能なファイルディスクリプター以外は 集合から削除される。
+.TP 
 \fIwritefds\fP
-.\"O This set is watched to see if there is space to write data to any of
-.\"O its file descriptors.
-.\"O After
-.\"O .BR select ()
-.\"O has returned, \fIwritefds\fP will be
-.\"O cleared of all file descriptors except for those that
-.\"O are immediately available for writing.
-この集合に含まれるいずれかのファイルディスクリプタで、
-データを書き込むスペースがあるかどうかを監視する。
-.BR select ()
-から戻る時に、\fIwritefds\fP のうち、
-直ちに書き込み可能なファイルディスクリプタ以外は
-集合から削除される。
-.TP
+この集合に含まれるいずれかのファイルディスクリプターで、 データを書き込むスペースがあるかどうかを監視する。 \fBselect\fP()
+から戻る時に、\fIwritefds\fP のうち、 直ちに書き込み可能なファイルディスクリプター以外は 集合から削除される。
+.TP 
 \fIexceptfds\fP
-.\"O This set is watched for "exceptional conditions".
-.\"O In practice, only one such exceptional condition is common:
-.\"O the availability of \fIout-of-band\fP (OOB) data for reading
-.\"O from a TCP socket.
-.\"O See
-.\"O .BR recv (2),
-.\"O .BR send (2),
-.\"O and
-.\"O .BR tcp (7)
-.\"O for more details about OOB data.
-.\"O (One other less common case where
-.\"O .BR select (2)
-.\"O indicates an exceptional condition occurs with pseudoterminals
-.\"O in packet mode; see
-.\"O .BR tty_ioctl (4).)
-.\"O After
-.\"O .BR select ()
-.\"O has returned,
-.\"O \fIexceptfds\fP will be cleared of all file descriptors except for those
-.\"O for which an exceptional condition has occurred.
-この集合に含まれるいずれかのファイルディスクリプタで、
-「例外状態 (exceptional condition)」が発生したかどうかを監視する。
-実際の動作では、普通に起こり得る例外状態は一つだけであり、
-それは TCP ソケットで \fI帯域外 (out-of-band; OOB)\fP データが
-読み込み可能な場合である。
-OOB データの詳細については、
-.BR recv (2),
-.BR send (2),
-.BR tcp (7)
-を参照のこと。
-(これ以外では、まれなことだが、
-パケットモードの擬似端末 (pseudoterminals) で
-.BR select ()
-が例外状態を示すことがある。)
-.BR select ()
-が返る時に、\fIexceptfds\fP のうち、
-例外状態が発生したディスクリプタ以外は集合から削除される。
-.TP
+この集合に含まれるいずれかのファイルディスクリプターで、 「例外状態 (exceptional condition)」が発生したかどうかを監視する。
+実際の動作では、普通に起こり得る例外状態は一つだけであり、 それは TCP ソケットで \fI帯域外 (out\-of\-band; OOB)\fP データが
+読み込み可能な場合である。 OOB データの詳細については、 \fBrecv\fP(2), \fBsend\fP(2), \fBtcp\fP(7)  を参照のこと。
+(これ以外では、まれなことだが、 パケットモードの擬似端末 (pseudoterminals) で \fBselect\fP()
+が例外状態を示すことがある。)  \fBselect\fP()  が返る時に、\fIexceptfds\fP のうち、
+例外状態が発生したディスクリプター以外は集合から削除される。
+.TP 
 \fInfds\fP
-.\"O This is an integer one more than the maximum of any file descriptor in
-.\"O any of the sets.
-.\"O In other words, while adding file descriptors to each of the sets,
-.\"O you must calculate the maximum integer value of all of them,
-.\"O then increment this value by one, and then pass this as \fInfds\fP.
-全ての集合に含まれるファイルディスクリプタのうち、
-値が最大のものに 1 を足した整数である。
-すなわち、ファイルディスクリプタを各集合に加える作業の途中で、
-全てのファイルディスクリプタを見て最大値を求め、
-それに 1 を加えて \fInfds\fP として渡さないといけない、ということだ。
-.TP
+全ての集合に含まれるファイルディスクリプターのうち、 値が最大のものに 1 を足した整数である。
+すなわち、ファイルディスクリプターを各集合に加える作業の途中で、 全てのファイルディスクリプターを見て最大値を求め、 それに 1 を加えて
+\fInfds\fP として渡さないといけない、ということだ。
+.TP 
 \fIutimeout\fP
-.\"O This is the longest time
-.\"O .BR select ()
-.\"O may wait before returning, even if nothing interesting happened.
-.\"O If this value is passed as NULL, then
-.\"O .BR select ()
-.\"O blocks indefinitely waiting for a file descriptor to become ready.
-.\"O \fIutimeout\fP can be set to zero seconds, which causes
-.\"O .BR select ()
-.\"O to return immediately, with information about the readiness
-.\"O of file descriptors at the time of the call.
-.\"O The structure \fIstruct timeval\fP is defined as:
-(何も起こらなかった場合に)
-.BR select ()
-が戻る前に待つ最大時間である。
-この値に NULL を渡すと、
-.BR select ()
-はファイルディスクリプタのいずれかが ready (準備ができた) 状態に
-なるまで待ち続けてずっと停止する。
-\fIutimeout\fP は 0 秒にすることもでき、
-この場合
-.BR select ()
-は直ちに返り、呼び出し時点のファイルディスクリプタの状態に
-関する情報が返される。
-構造体 \fIstruct timeval\fP は次のように定義されている:
+(何も起こらなかった場合に)  \fBselect\fP()  が戻る前に待つ最大時間である。 この値に NULL を渡すと、 \fBselect\fP()
+はファイルディスクリプターのいずれかが ready (準備ができた) 状態に なるまで待ち続けてずっと停止する。 \fIutimeout\fP は 0
+秒にすることもでき、 この場合 \fBselect\fP()  は直ちに返り、呼び出し時点のファイルディスクリプターの状態に 関する情報が返される。 構造体
+\fIstruct timeval\fP は次のように定義されている:
 .IP
 .in +4n
 .nf
@@ -271,21 +130,11 @@ struct timeval {
 };
 .fi
 .in
-.TP
+.TP 
 \fIntimeout\fP
-.\"O This argument for
-.\"O .BR pselect ()
-.\"O has the same meaning as
-.\"O .IR utimeout ,
-.\"O but
-.\"O .I "struct timespec"
-.\"O has nanosecond precision as follows:
-.BR pselect ()
-のこの引き数は
-.I utimeout
-と同じ意味を持つが、
-.I "struct timespec"
+\fBpselect\fP()  のこの引き数は \fIutimeout\fP と同じ意味を持つが、 \fIstruct timespec\fP
 は次に示すようにナノ秒の精度を持つ。
+.IP
 .in +4n
 .nf
 struct timespec {
@@ -294,130 +143,25 @@ struct timespec {
 };
 .fi
 .in
-.TP
+.TP 
 \fIsigmask\fP
-.\"O This argument holds a set of signals that the kernel should unblock
-.\"O (i.e., remove from the signal mask of the calling thread),
-.\"O while the caller is blocked inside the
-.\"O .BR pselect ()
-.\"O call (see
-.\"O .BR sigaddset (3)
-.\"O and
-.\"O .BR sigprocmask (2)).
-.\"O It may be NULL,
-.\"O in which case the call does not modify the signal mask on
-.\"O entry and exit to the function.
-.\"O In this case,
-.\"O .BR pselect ()
-.\"O will then behave just like
-.\"O .BR select ().
-この引き数は、呼び出し側が
-.BR pselect ()
-内部で停止している間に、カーネルが通知を許可すべきシグナル集合
-(すなわち、呼び出したスレッドのシグナルマスクから削除すべきシグナル集合)
-を保持する
-.RB ( sigaddset (3)
-と
-.BR sigprocmask (2)
-を参照)。
-この引き数は NULL にすることもでき、その場合はこの関数へ
-入るとき・出るときにシグナルマスクを変更しない。
-この場合、
-.BR pselect ()
-は
-.BR select ()
-と全く同じ動作となる。
-.\"O .SS Combining Signal and Data Events
+この引き数は、呼び出し側が \fBpselect\fP()  内部で停止している間に、カーネルが通知を許可すべきシグナル集合
+(すなわち、呼び出したスレッドのシグナルマスクから削除すべきシグナル集合)  を保持する (\fBsigaddset\fP(3)  と
+\fBsigprocmask\fP(2)  を参照)。 この引き数は NULL にすることもでき、その場合はこの関数へ
+入るとき・出るときにシグナルマスクを変更しない。 この場合、 \fBpselect\fP()  は \fBselect\fP()  と全く同じ動作となる。
 .SS シグナルとデータイベントを組み合わせる
-.\"O .BR pselect ()
-.\"O is useful if you are waiting for a signal as well as
-.\"O for file descriptor(s) to become ready for I/O.
-.\"O Programs that receive signals
-.\"O normally use the signal handler only to raise a global flag.
-.\"O The global flag will indicate that the event must be processed
-.\"O in the main loop of the program.
-ファイルディスクリプタが I/O 可能な状態になるのと同時に
-シグナルも待ちたい場合には、
-.BR pselect ()
-が便利である。
-シグナルを受信するプログラムは、通常は、
-シグナルハンドラをグローバルなフラグを立てるためだけに使う。
-このグローバルなフラグは、
-そのイベントをプログラムのメインループで
-処理しなければならないことを示す。
-.\"O A signal will cause the
-.\"O .BR select ()
-.\"O (or
-.\"O .BR pselect ())
-.\"O call to return with \fIerrno\fP set to \fBEINTR\fP.
-.\"O This behavior is essential so that signals can be processed
-.\"O in the main loop of the program, otherwise
-.\"O .BR select ()
-.\"O would block indefinitely.
-シグナルを受けると
-.BR select ()
-(や
-.BR pselect ())
-は
-\fIerrno\fP に \fBEINTR\fP をセットして戻ることになる。
-シグナルがプログラムのメインループで処理されるためにはこの動作が不可欠で、
-これがないと
-.BR select ()
-は永遠に停止し続けることになる。
-.\"O Now, somewhere
-.\"O in the main loop will be a conditional to check the global flag.
-.\"O So we must ask:
-.\"O what if a signal arrives after the conditional, but before the
-.\"O .BR select ()
-.\"O call?
-.\"O The answer is that
-.\"O .BR select ()
-.\"O would block indefinitely, even though an event is actually pending.
-さて、メインループのどこかにこのグローバルフラグをチェックする
-条件文があるとしよう。ここで少し考えてみないといけない。
-「シグナルが条件文の後、しかし
-.BR select ()
-コールの前に到着したら
-どうなるのか?」
-答えは「その
-.BR select ()
-は、たとえ解決待ちのイベントがあったとしても、
-永遠に停止する」である。
-.\"O This race condition is solved by the
-.\"O .BR pselect ()
-.\"O call.
-.\"O This call can be used to set the signal mask to a set of signals
-.\"O that are only to be received within the
-.\"O .BR pselect ()
-.\"O call.
-この競合状態は
-.BR pselect ()
-コールによって解決できる。
-このコールを使うと、
-.BR pselect ()
-で受信したいシグナルの集合だけをシグナルマスクに設定することができる。
-.\"O For instance, let us say that the event in question
-.\"O was the exit of a child process.
-.\"O Before the start of the main loop, we
-.\"O would block \fBSIGCHLD\fP using
-.\"O .BR sigprocmask (2).
-.\"O Our
-.\"O .BR pselect ()
-.\"O call would enable
-.\"O .B SIGCHLD
-.\"O by using an empty signal mask.
-.\"O Our program would look like:
-例えば、問題となっているイベントが子プロセスの終了の場合を考えよう。
-メインループが始まる前に、
-.B SIGCHLD
-を
-.BR sigprocmask (2)
-でブロックする。
-.BR pselect ()
-コールでは
-.B SIGCHLD
-を、もともとのシグナルマスクを使って有効にするのだ。
-このプログラムは次のようになる。
+ファイルディスクリプターが I/O 可能な状態になるのと同時に シグナルも待ちたい場合には、 \fBpselect\fP()  が便利である。
+シグナルを受信するプログラムは、通常は、 シグナルハンドラーをグローバルなフラグを立てるためだけに使う。 このグローバルなフラグは、
+そのイベントをプログラムのメインループで 処理しなければならないことを示す。 シグナルを受けると \fBselect\fP()  (や
+\fBpselect\fP())  は \fIerrno\fP に \fBEINTR\fP をセットして戻ることになる。
+シグナルがプログラムのメインループで処理されるためにはこの動作が不可欠で、 これがないと \fBselect\fP()  は永遠に停止し続けることになる。
+さて、メインループのどこかにこのグローバルフラグをチェックする 条件文があるとしよう。ここで少し考えてみないといけない。 「シグナルが条件文の後、しかし
+\fBselect\fP()  コールの前に到着したら どうなるのか?」 答えは「その \fBselect\fP()
+は、たとえ解決待ちのイベントがあったとしても、 永遠に停止する」である。 この競合状態は \fBpselect\fP()  コールによって解決できる。
+このコールを使うと、 \fBpselect\fP() でのみ受信したいシグナルの集合をシグナルマスクに設定することができる。
+例えば、問題となっているイベントが子プロセスの終了の場合を考えよう。 メインループが始まる前に、 \fBSIGCHLD\fP を
+\fBsigprocmask\fP(2)  でブロックする。 \fBpselect\fP()  コールでは \fBSIGCHLD\fP
+を、もともとのシグナルマスクを使って有効にするのだ。 このプログラムは次のようになる。
 .PP
 .nf
 static volatile sig_atomic_t got_SIGCHLD = 0;
@@ -474,301 +218,83 @@ main(int argc, char *argv[])
     }
 }
 .fi
-.\"O .SS Practical
 .SS 実例
-.\"O So what is the point of
-.\"O .BR select ()?
-.\"O Can't I just read and write to my descriptors whenever I want?
-.\"O The point of
-.\"O .BR select ()
-.\"O is that it watches
-.\"O multiple descriptors at the same time and properly puts the process to
-.\"O sleep if there is no activity.
-.\"O UNIX programmers often find
-.\"O themselves in a position where they have to handle I/O from more than one
-.\"O file descriptor where the data flow may be intermittent.
-.\"O If you were to merely create a sequence of
-.\"O .BR read (2)
-.\"O and
-.\"O .BR write (2)
-.\"O calls, you would
-.\"O find that one of your calls may block waiting for data from/to a file
-.\"O descriptor, while another file descriptor is unused though ready for I/O.
-.\"O .BR select ()
-.\"O efficiently copes with this situation.
-実際のところ
-.BR select ()
-の大事な点は何なのか?
-ディスクリプタは好きなときに読み書きできるんじゃないの?
-.BR select ()
-の重要なところは、複数のディスクリプタを同時に監視でき、
-なんの動きもなければプロセスを適切にスリープ状態に移行するところにあるのだ。
-UNIX プログラマは、
-複数のファイルディスクリプタの入出力を同時に扱わねばならず、
-しかもデータの流れは間欠的である、という状況によく出会う。
-単に
-.BR read (2)
-や
-.BR write (2)
-コールのシーケンスを作るだけでは、それらのコールのどれかが
-ファイルディスクリプタからのデータを待ってブロックしており、
-別のファイルディスクリプタには I/O が可能なのに使えない、
-ということになってしまうだろう。
-.BR select ()
-を使うとこの状況に効果的に対処できる。
-.\"O .SS Select Law
-.SS SELECT の掟
-.\"O Many people who try to use
-.\"O .BR select ()
-.\"O come across behavior that is
-.\"O difficult to understand and produces nonportable or borderline results.
-.\"O For instance, the above program is carefully written not to
-.\"O block at any point, even though it does not set its file descriptors to
-.\"O nonblocking mode.
-.\"O It is easy to introduce
-.\"O subtle errors that will remove the advantage of using
-.\"O .BR select (),
-.\"O so here is a list of essentials to watch for when using
-.\"O .BR select ().
-.BR select ()
-を使おうとした多くの人は、理解しにくい挙動に出くわし、結果的に
-できたものは移植性がないか、よくてもギリギリのものになってしまう。
-例えば、上記のプログラムは、
-集合に含まれるファイルディスクリプタを非停止 (nonblocking) モード
-にしなくても、どこにもブロックが生じないよう注意して書かれている。
-微妙な間違いによって、
-.BR select ()
-を使う利点は簡単に失われてしまう。
-そこで、
-.BR select ()
-コールを使うときに注意すべき重要事項を列挙しておくことにする。
-.TP 4
+実際のところ \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.
-.\"O You should always try to use
-.\"O .BR select ()
-.\"O without a timeout.
-.\"O Your program
-.\"O should have nothing to do if there is no data available.
-.\"O Code that
-.\"O depends on timeouts is not usually portable and is difficult to debug.
-.BR select ()
-を使うときは、タイムアウトは設定すべきでない。
-処理するデータが無いときには、
-あなたのプログラムには何もすることは無いはずである。
-タイムアウトに依存したコードは通常移植性がなく、
-デバッグも難しくなる。
-.TP
+\fBselect\fP()  を使うときは、タイムアウトは設定すべきでない。 処理するデータが無いときには、
+あなたのプログラムには何もすることは無いはずである。 タイムアウトに依存したコードは通常移植性がなく、 デバッグも難しくなる。
+.TP 
 2.
-.\"O The value \fInfds\fP must be properly calculated for efficiency as
-.\"O explained above.
-上述したように、
-効率的なプログラムを書くには
-.I nfds
-の値を適切に計算して与えなければならない。
-.TP
+上述したように、 効率的なプログラムを書くには \fInfds\fP の値を適切に計算して与えなければならない。
+.TP 
 3.
-.\"O No file descriptor must be added to any set if you do not intend
-.\"O to check its result after the
-.\"O .BR select ()
-.\"O call, and respond appropriately.
-.\"O See next rule.
-.BR select ()
-コールの終了後に結果をチェックして、
-適切に対応するつもりのないファイルディスクリプタは、
-どの集合にも加えてはならない。
+\fBselect\fP()  コールの終了後に結果をチェックして、 適切に対応するつもりのないファイルディスクリプターは、 どの集合にも加えてはならない。
 次のルールも参照。
-.TP
+.TP 
 4.
-.\"O After
-.\"O .BR select ()
-.\"O returns, all file descriptors in all sets
-.\"O should be checked to see if they are ready.
-.BR select ()
-から返った後には、全ての集合の全てのファイルディスクリプタについて
-読み書き可能な状態になっているかをチェックすべきである。
-.TP
+\fBselect\fP()  から返った後には、全ての集合の全てのファイルディスクリプターについて 読み書き可能な状態になっているかをチェックすべきである。
+.TP 
 5.
-.\"O The functions
-.\"O .BR read (2),
-.\"O .BR recv (2),
-.\"O .BR write (2),
-.\"O and
-.\"O .BR send (2)
-.\"O do \fInot\fP necessarily read/write the full amount of data
-.\"O that you have requested.
-.\"O If they do read/write the full amount, it's
-.\"O because you have a low traffic load and a fast stream.
-.\"O This is not always going to be the case.
-.\"O You should cope with the case of your
-.\"O functions only managing to send or receive a single byte.
-.BR read (2),
-.BR recv (2),
-.BR write (2),
-.BR send (2)
-といった関数は、こちらが要求した全データを読み書きする必要は\fIない\fP。
-もし全データを読み書きするなら、それはトラフィックの負荷が小さく、
-ストリームが速い場合だろう。この条件は常に満たされるとは限らない。
-これらの関数が頑張っても 1 バイトしか送受信できないような場合も
+\fBread\fP(2), \fBrecv\fP(2), \fBwrite\fP(2), \fBsend\fP(2)
+といった関数は、こちらが要求した全データを読み書きする必要は\fIない\fP。 もし全データを読み書きするなら、それはトラフィックの負荷が小さく、
+ストリームが速い場合だろう。この条件は常に満たされるとは限らない。 これらの関数が頑張っても 1 バイトしか送受信できないような場合も
 考慮に入れてやらなければならない。
-.TP
+.TP 
 6.
-.\"O Never read/write only in single bytes at a time unless you are really
-.\"O sure that you have a small amount of data to process.
-.\"O It is extremely
-.\"O inefficient not to read/write as much data as you can buffer each time.
-.\"O The buffers in the example below are 1024 bytes although they could
-.\"O easily be made larger.
-処理するデータ量が小さいことがはっきりとわかっている場合を除いて、
-一度に 1 バイトずつ読み書きするようなことはしてはならない。
-バッファの許すかぎりのデータをまとめて読み書きしないと、
-非常に効率が悪い。下記の例ではバッファは 1024 バイトにしているが、
+処理するデータ量が小さいことがはっきりとわかっている場合を除いて、 一度に 1 バイトずつ読み書きするようなことはしてはならない。
+バッファーの許すかぎりのデータをまとめて読み書きしないと、 非常に効率が悪い。下記の例ではバッファーは 1024 バイトにしているが、
 このサイズを大きくするのは簡単だろう。
-.TP
+.TP 
 7.
-.\"O The functions
-.\"O .BR read (2),
-.\"O .BR recv (2),
-.\"O .BR write (2),
-.\"O and
-.\"O .BR send (2)
-.\"O as well as the
-.\"O .BR select ()
-.\"O call can return \-1 with
-.\"O .I errno
-.\"O set to \fBEINTR\fP,
-.\"O or with
-.\"O .I errno
-.\"O set to \fBEAGAIN\fP (\fBEWOULDBLOCK\fP).
-.\"O These results must be properly managed (not done properly above).
-.\"O If your program is not going to receive any signals, then
-.\"O it is unlikely you will get \fBEINTR\fP.
-.\"O If your program does not set nonblocking I/O,
-.\"O you will not get \fBEAGAIN\fP.
-.\"O .\" Nonetheless, you should still cope with these errors for completeness.
-.BR read (2),
-.BR recv (2),
-.BR write (2),
-.BR send (2)
-などの関数や
-.BR select ()
-コールは、
-.I errno
-を
-.B EINTR " や " EAGAIN
-.RB ( EWOULDBLOCK )
-にして \-1 を返すことがある。
-このような結果に対して適切に対応してやらなければならない
-(上記の例ではしていない)。
-書いているプログラムがシグナルを受ける予定がなければ、
-.B EINTR
-が返されることはあまり考えられない。
-書いているプログラムで非ブロック I/O をセットしていない場合は、
-.B EAGAIN
+.\" Nonetheless, you should still cope with these errors for completeness.
+\fBread\fP(2), \fBrecv\fP(2), \fBwrite\fP(2), \fBsend\fP(2)  などの関数や \fBselect\fP()  コールは、
+\fIerrno\fP を \fBEINTR や EAGAIN\fP (\fBEWOULDBLOCK\fP)  にして \-1 を返すことがある。
+このような結果に対して適切に対応してやらなければならない (上記の例ではしていない)。 書いているプログラムがシグナルを受ける予定がなければ、
+\fBEINTR\fP が返されることはあまり考えられない。 書いているプログラムで非ブロック I/O をセットしていない場合は、 \fBEAGAIN\fP
 が返されることはないだろう。
-.\" それでもなお、完全を期するならば、
-.\" これらのエラーを考慮に入れる必要がある。
-.TP
+.TP 
 8.
-.\"O Never call
-.\"O .BR read (2),
-.\"O .BR recv (2),
-.\"O .BR write (2),
-.\"O or
-.\"O .BR send (2)
-.\"O with a buffer length of zero.
-決して、引き数に長さ 0 のバッファを指定して
-.BR read (2),
-.BR recv (2),
-.BR write (2),
-.BR send (2)
+決して、引き数に長さ 0 のバッファーを指定して \fBread\fP(2), \fBrecv\fP(2), \fBwrite\fP(2), \fBsend\fP(2)
 を呼び出してはならない。
-.TP
+.TP 
 9.
-.\"O If the functions
-.\"O .BR read (2),
-.\"O .BR recv (2),
-.\"O .BR write (2),
-.\"O and
-.\"O .BR send (2)
-.\"O fail with errors other than those listed in \fB7.\fP,
-.\"O or one of the input functions returns 0, indicating end of file,
-.\"O then you should \fInot\fP pass that descriptor to
-.\"O .BR select ()
-.\"O again.
-.\"O In the example below,
-.\"O I close the descriptor immediately, and then set it to \-1
-.\"O to prevent it being included in a set.
-.BR read (2),
-.BR recv (2),
-.BR write (2),
-.BR send (2)
-が
-\fB7.\fP に示した以外のエラーで失敗した場合や、
-入力系の関数の一つがファイル末尾を表す 0 を返した場合は、
-そのディスクリプタをもう一度 select に渡しては\fIならない\fP。
-下記の例では、そのディスクリプタをただちにクローズし、
-そこには \-1 をセットして、
-それが集合に含まれ続けるのを許さないようにしている。
-.TP
+\fBread\fP(2), \fBrecv\fP(2), \fBwrite\fP(2), \fBsend\fP(2)  が \fB7.\fP に示した以外のエラーで失敗した場合や、
+入力系の関数の一つがファイル末尾を表す 0 を返した場合は、 そのディスクリプターをもう一度 select に渡しては\fIならない\fP。
+下記の例では、そのディスクリプターをただちにクローズし、 そこには \-1 をセットして、 それが集合に含まれ続けるのを許さないようにしている。
+.TP 
 10.
-.\"O The timeout value must be initialized with each new call to
-.\"O .BR select (),
-.\"O since some operating systems modify the structure.
-.\"O .BR pselect ()
-.\"O however does not modify its timeout structure.
-タイムアウトの値は
-.BR select ()
-を呼ぶたびに初期化すべきである。
-OS によっては timeout 構造体が変更される場合があるからである。
-但し、
-.BR pselect ()
-は自分の timeout 構造体を変更することはない。
-.TP
+タイムアウトの値は \fBselect\fP()  を呼ぶたびに初期化すべきである。 OS によっては timeout
+構造体が変更される場合があるからである。 但し、 \fBpselect\fP()  は自分の timeout 構造体を変更することはない。
+.TP 
 11.
-.\"O Since
-.\"O .BR select ()
-.\"O modifies its file descriptor sets,
-.\"O if the call is being used in a loop,
-.\"O then the sets must be reinitialized before each call.
-.BR select ()
-はファイルディスクリプタ集合を変更するので、
-.BR select ()
-がループの中で使用されている場合には、呼び出しを行う前に毎回
-ディスクリプタ集合を初期化し直さなければならない。
 .\" "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
-.\"O .\" 11.
-.\"O .\" I have heard that the Windows socket layer does not cope with OOB data
-.\"O .\" properly.
-.\"O .\" It also does not cope with
-.\"O .\" .BR select ()
-.\"O .\" calls when no file descriptors are set at all.
-.\"O .\" Having no file descriptors set is a useful
-.\"O .\" way to sleep the process with subsecond precision by using the timeout.
-.\"O .\" (See further on.)
-.\" 聞いたところでは、Windows のソケット層は
-.\" OOB データを正しく処理しないらしい。
-.\" また、ファイルディスクリプタが全くセットされていないような
+.\" 11.
+.\" I have heard that the Windows socket layer does not cope with OOB data
+.\" properly.
+.\" It also does not cope with
 .\" .BR select ()
-.\" コールも正しく処理しないらしい。
-.\" ファイルディスクリプタを一切設定しないで timeout を使うやり方は、
-.\" 1 秒以下の精度でプロセスをスリープさせるには便利な方法なのだが
-.\" (続きを見よ)。
-.\"O .SS Usleep Emulation
-.SS usleep エミュレーション
-.\"O On systems that do not have a
-.\"O .BR usleep (3)
-.\"O function, you can call
-.\"O .BR select ()
-.\"O with a finite timeout and no file descriptors as
-.\"O follows:
-.BR usleep (3)
-関数を持たないシステムでは、
-有限のタイムアウトを指定し、ファイルディスクリプタを全くセットせずに
-.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()
+がループの中で使用されている場合には、呼び出しを行う前に毎回 ディスクリプター集合を初期化し直さなければならない。
+.SS "usleep エミュレーション"
+\fBusleep\fP(3)  関数を持たないシステムでは、 有限のタイムアウトを指定し、ファイルディスクリプターを全くセットせずに \fBselect\fP()
+を呼び出すことで、これを代用できる。 以下のようにする。
 .PP
 .nf
     struct timeval tv;
@@ -777,105 +303,29 @@ OS によっては timeout 構造体が変更される場合があるからで
     select(0, NULL, NULL, NULL, &tv);
 .fi
 .PP
-.\"O This is only guaranteed to work on UNIX systems, however.
 但し、これが動くと保証されているのは UNIX システムに限られる。
-.\"O .SH RETURN VALUE
 .SH 返り値
-.\"O On success,
-.\"O .BR select ()
-.\"O returns the total number of file descriptors
-.\"O still present in the file descriptor sets.
-成功すると、
-.BR select ()
-はファイルディスクリプタ集合に残っている
-ファイルディスクリプタの総数を返す。
+成功すると、 \fBselect\fP()  はファイルディスクリプター集合に残っている ファイルディスクリプターの総数を返す。
 
-.\"O If
-.\"O .BR select ()
-.\"O timed out, then the return value will be zero.
-.\"O The file descriptors set should be all
-.\"O empty (but may not be on some systems).
-.BR select ()
-がタイムアウトすると、返り値は 0 になる。
-その時、ファイルディスクリプタ集合はすべて空である
+\fBselect\fP()  がタイムアウトすると、返り値は 0 になる。 その時、ファイルディスクリプター集合はすべて空である
 (しかしそうならないシステムもある)。
 
-.\"O A return value of \-1 indicates an error, with \fIerrno\fP being
-.\"O set appropriately.
-.\"O In the case of an error, the contents of the returned sets and
-.\"O the \fIstruct timeout\fP contents are undefined and should not be used.
-.\"O .BR pselect ()
-.\"O however never modifies \fIntimeout\fP.
-返り値が \-1 の場合はエラーを意味し、
-.I errno
-が適切にセットされる。エラーが起こった場合、
-返された集合の内容や構造体 \fIstruct timeout\fP の内容は
-未定義となっており、使用すべきではない。
-しかし
-.BR pselect ()
-は決して
-.I ntimeout
+返り値が \-1 の場合はエラーを意味し、 \fIerrno\fP が適切にセットされる。エラーが起こった場合、 返された集合の内容や構造体 \fIstruct
+timeout\fP の内容は 未定義となっており、使用すべきではない。 しかし \fBpselect\fP()  は決して \fIntimeout\fP
 を変更しない。
-.\"O .SH NOTES
 .SH 注意
-.\"O Generally speaking,
-.\"O all operating systems that support sockets also support
-.\"O .BR select ().
-.\"O .BR select ()
-.\"O can be used to solve
-.\"O many problems in a portable and efficient way that naive programmers try
-.\"O to solve in a more complicated manner using
-.\"O threads, forking, IPCs, signals, memory sharing, and so on.
-一般的に言って、ソケットをサポートする全てのオペレーティングシステムは
-.BR select ()
-もサポートしている。
-.BR select ()
-を使うと、プログラマがスレッド、フォーク、IPC、シグナル、メモリ共有、
-等々を使ってもっと複雑な方法で解決しようとする多くの問題が、
+一般的に言って、ソケットをサポートする全てのオペレーティングシステムは \fBselect\fP()  もサポートしている。 \fBselect\fP()
+を使うと、プログラマがスレッド、フォーク、IPC、シグナル、メモリー共有、 等々を使ってもっと複雑な方法で解決しようとする多くの問題が、
 移植性がありかつ効率的な方法で解決できる。
 .PP
-.\"O The
-.\"O .BR poll (2)
-.\"O system call has the same functionality as
-.\"O .BR select (),
-.\"O and is somewhat more efficient when monitoring sparse
-.\"O file descriptor sets.
-.\"O It is nowadays widely available, but historically was less portable than
-.\"O .BR select ().
-.BR poll (2)
-システムコールは
-.BR select ()
-と同じ機能を持っており、
-まばらなファイルディスクリプタ集合を監視する場合に
-いくらか効率がよい。
-現在では広く利用可能であるが、以前は
-.BR select ()
-より移植性の面で劣っていた。
+\fBpoll\fP(2)  システムコールは \fBselect\fP()  と同じ機能を持っており、 まばらなファイルディスクリプター集合を監視する場合に
+いくらか効率がよい。 現在では広く利用可能であるが、以前は \fBselect\fP()  より移植性の面で劣っていた。
 .PP
-.\"O The Linux-specific
-.\"O .BR epoll (7)
-.\"O API provides an interface that is more efficient than
-.\"O .BR select (2)
-.\"O and
-.\"O .BR poll (2)
-.\"O when monitoring large numbers of file descriptors.
-Linux 独自の
-.BR epoll (7)
-API は、多数のファイルディスクリプタを監視する場合に
-.BR select (2)
-や
-.BR poll (2)
-よりも効率的なインタフェースを提供している。
-.\"O .SH EXAMPLE
+Linux 独自の \fBepoll\fP(7)  API は、多数のファイルディスクリプターを監視する場合に \fBselect\fP(2)  や
+\fBpoll\fP(2)  よりも効率的なインターフェースを提供している。
 .SH 例
-.\"O Here is an example that better demonstrates the true utility of
-.\"O .BR select ().
-.\"O The listing below a TCP forwarding program that forwards
-.\"O from one TCP port to another.
-.BR select ()
-の本当に便利な点を示す、よい例を紹介する。
-以下のリストは、ある TCP ポートから別のポートへ転送を行う
-TCP フォワードプログラムである。
+\fBselect\fP()  の本当に便利な点を示す、よい例を紹介する。 以下のリストは、ある TCP ポートから別のポートへ転送を行う TCP
+フォワードプログラムである。
 .PP
 .nf
 #include <stdlib.h>
@@ -908,7 +358,7 @@ listen_socket(int listen_port)
     }
     yes = 1;
     if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
-            (char *) &yes, sizeof(yes)) == \-1) {
+            &yes, sizeof(yes)) == \-1) {
         perror("setsockopt");
         close(s);
         return \-1;
@@ -921,7 +371,7 @@ listen_socket(int listen_port)
         close(s);
         return \-1;
     }
-    printf("accepting connections on port %d\\n", listen_port);
+    printf("accepting connections on port %d\en", listen_port);
     listen(s, 10);
     return s;
 }
@@ -932,7 +382,8 @@ connect_socket(int connect_port, char *address)
     struct sockaddr_in a;
     int s;
 
-    if ((s = socket(AF_INET, SOCK_STREAM, 0)) == \-1) {
+    s = socket(AF_INET, SOCK_STREAM, 0);
+    if (s == \-1) {
         perror("socket");
         close(s);
         return \-1;
@@ -957,20 +408,20 @@ connect_socket(int connect_port, char *address)
     return s;
 }
 
-#define SHUT_FD1 do {                                \\
-                     if (fd1 >= 0) {                 \\
-                         shutdown(fd1, SHUT_RDWR);   \\
-                         close(fd1);                 \\
-                         fd1 = \-1;                   \\
-                     }                               \\
+#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 {                                \\
-                     if (fd2 >= 0) {                 \\
-                         shutdown(fd2, SHUT_RDWR);   \\
-                         close(fd2);                 \\
-                         fd2 = \-1;                   \\
-                     }                               \\
+#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
@@ -985,8 +436,8 @@ main(int argc, char *argv[])
     int buf2_avail, buf2_written;
 
     if (argc != 4) {
-        fprintf(stderr, "Usage\\n\\tfwd <listen-port> "
-                 "<forward-to-port> <forward-to-ip-address>\\n");
+        fprintf(stderr, "Usage\en\etfwd <listen\-port> "
+                 "<forward\-to\-port> <forward\-to\-ip\-address>\en");
         exit(EXIT_FAILURE);
     }
 
@@ -1060,7 +511,7 @@ main(int argc, char *argv[])
                 if (fd2 == \-1)
                     SHUT_FD1;
                 else
-                    printf("connect from %s\\n",
+                    printf("connect from %s\en",
                             inet_ntoa(client_address.sin_addr));
             }
         }
@@ -1143,57 +594,22 @@ main(int argc, char *argv[])
 }
 .fi
 .PP
-.\"O The above program properly forwards most kinds of TCP connections
-.\"O including OOB signal data transmitted by \fBtelnet\fP servers.
-.\"O It handles the tricky problem of having data flow in both directions
-.\"O simultaneously.
-.\"O You might think it more efficient to use a
-.\"O .BR fork (2)
-.\"O call and devote a thread to each stream.
-.\"O This becomes more tricky than you might suspect.
-.\"O Another idea is to set nonblocking I/O using
-.\"O .BR fcntl (2).
-.\"O This also has its problems because you end up using
-.\"O inefficient timeouts.
-上記のプログラムは、ほとんどの種類の TCP 接続をフォワードする。
-.B telnet
-サーバによって中継される OOB シグナルデータも扱える。
-このプログラムは、データフローを双方向に同時に送るという、
-ややこしい問題も処理できる。
-.BR fork (2)
-コールを使って、各ストリームごとに専用のスレッドを用いるほうが効率的だ、
-という人もいるかもしれない。しかし、これは考えているよりずっとややこしい。
-あるいは、
-.BR fcntl (2)
-を使って非ブロック I/O をセットすれば良い、というアイデアもあるだろう。
+上記のプログラムは、ほとんどの種類の TCP 接続をフォワードする。 \fBtelnet\fP サーバによって中継される OOB シグナルデータも扱える。
+このプログラムは、データフローを双方向に同時に送るという、 ややこしい問題も処理できる。 \fBfork\fP(2)
+コールを使って、各ストリームごとに専用のスレッドを用いるほうが効率的だ、 という人もいるかもしれない。しかし、これは考えているよりずっとややこしい。
+あるいは、 \fBfcntl\fP(2)  を使って非ブロック I/O をセットすれば良い、というアイデアもあるだろう。
 これにも実際には問題があり、タイムアウトが非効率的に起こってしまう。
 
-.\"O The program does not handle more than one simultaneous connection at a
-.\"O time, although it could easily be extended to do this with a linked list
-.\"O of buffers\(emone for each connection.
-.\"O At the moment, new
-.\"O connections cause the current connection to be dropped.
-このプログラムは一度にひとつ以上の同時接続を扱うことはできないが、
-その様に拡張するのは簡単で、バッファのリンクリストを
-(接続ごとにひとつずつ) 使えばよい。
-現時点のものでは、新しい接続がくると古い接続は落ちてしまう。
-.\"O .SH SEE ALSO
+このプログラムは一度にひとつ以上の同時接続を扱うことはできないが、 その様に拡張するのは簡単で、バッファーのリンクリストを (接続ごとにひとつずつ)
+使えばよい。 現時点のものでは、新しい接続がくると古い接続は落ちてしまう。
 .SH 関連項目
-.BR accept (2),
-.BR connect (2),
-.BR ioctl (2),
-.BR poll (2),
-.BR read (2),
-.BR recv (2),
-.BR select (2),
-.BR send (2),
-.BR sigprocmask (2),
-.BR write (2),
-.BR sigaddset (3),
-.BR sigdelset (3),
-.BR sigemptyset (3),
-.BR sigfillset (3),
-.BR sigismember (3),
-.BR epoll (7)
 .\" .SH AUTHORS
 .\" This man page was written by Paul Sheer.
+\fBaccept\fP(2), \fBconnect\fP(2), \fBioctl\fP(2), \fBpoll\fP(2), \fBread\fP(2),
+\fBrecv\fP(2), \fBselect\fP(2), \fBsend\fP(2), \fBsigprocmask\fP(2), \fBwrite\fP(2),
+\fBsigaddset\fP(3), \fBsigdelset\fP(3), \fBsigemptyset\fP(3), \fBsigfillset\fP(3),
+\fBsigismember\fP(3), \fBepoll\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。