OSDN Git Service

c3570bdd316aa8ba6eb86279e413ff27088f3248
[linuxjm/LDP_man-pages.git] / draft / man7 / socket.7
1 '\" t
2 .\" Don't change the first line, it tells man that we need tbl.
3 .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
4 .\" and copyright (c) 1999 Matthew Wilcox.
5 .\" Permission is granted to distribute possibly modified copies
6 .\" of this page provided the header is included verbatim,
7 .\" and in case of nontrivial modification author and date
8 .\" of the modification is added to the header.
9 .\"
10 .\" 2002-10-30, Michael Kerrisk, <mtk.manpages@gmail.com>
11 .\"     Added description of SO_ACCEPTCONN
12 .\" 2004-05-20, aeb, added SO_RCVTIMEO/SO_SNDTIMEO text.
13 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
14 .\"     Added notes on capability requirements
15 .\"     A few small grammar fixes
16 .\" FIXME
17 .\" The following are not yet documented:
18 .\"     SO_PEERNAME
19 .\"     SO_TIMESTAMPNS
20 .\"     SO_MARK
21 .\"     SO_TIMESTAMPING
22 .\"     SO_PROTOCOL (2.6.32)
23 .\"     SO_DOMAIN (2.6.32)
24 .\"     SO_RXQ_OVFL (2.6.33)
25 .\"
26 .\" Japanese Version Copyright (c) 1999 NAKANO Takeo all rights reserved.
27 .\" Translated 1999-12-06, NAKANO Takeo <nakano@apm.seikei.ac.jp>
28 .\" Updated 2003-01-20, Akihiro Motoki <amotoki@dd.iij4u.or.jp>
29 .\" Updated 2005-02-23, Akihiro MOTOKI
30 .\" Updated 2005-10-05, Akihiro MOTOKI
31 .\" Updated 2005-12-05, Akihiro MOTOKI, Catch up to LDP man-pages 2.16
32 .\" Updated 2005-12-26, Akihiro MOTOKI, Catch up to LDP man-pages 2.18
33 .\" Updated 2006-04-15, Akihiro MOTOKI, Catch up to LDP man-pages 2.29
34 .\" Updated 2007-01-05, Akihiro MOTOKI, Catch up to LDP man-pages 2.43
35 .\"
36 .\"WORD         protocol family         プロトコルファミリー
37 .\"WORD         socket type             ソケットタイプ
38 .\"WORD         file descriptor         ファイルディスクリプタ
39 .\"WORD         anonymous socket        名前無しソケット
40 .\"WORD         asynchronous            非同期 (的)
41 .\"WORD         credential              信任状
42 .\"WORD         capability              権限
43 .\"WORD         ancillary data          補助データ
44 .\"
45 .TH SOCKET 7 2008-12-03 Linux "Linux Programmer's Manual"
46 .\"O .SH NAME
47 .SH 名前
48 .\"O socket \- Linux socket interface
49 socket \- Linux のソケットインターフェース
50 .\"O .SH SYNOPSIS
51 .SH 書式
52 .B #include <sys/socket.h>
53 .sp
54 .IB sockfd " = socket(int " socket_family ", int " socket_type ", int " protocol );
55 .\"O .SH DESCRIPTION
56 .SH 説明
57 .\"O This manual page describes the Linux networking socket layer user
58 .\"O interface.
59 .\"O The BSD compatible sockets
60 .\"O are the uniform interface
61 .\"O between the user process and the network protocol stacks in the kernel.
62 .\"O The protocol modules are grouped into
63 .\"O .I protocol families
64 .\"O like
65 .\"O .BR AF_INET ", " AF_IPX ", " AF_PACKET
66 .\"O and
67 .\"O .I socket types
68 .\"O like
69 .\"O .B SOCK_STREAM
70 .\"O or
71 .\"O .BR SOCK_DGRAM .
72 .\"O See
73 .\"O .BR socket (2)
74 .\"O for more information on families and types.
75 このマニュアルページは Linux ネットワークのソケット層に対する
76 ユーザインターフェースを記述するものである。
77 BSD 互換ソケットは、ユーザプロセスとカーネル内部の
78 ネットワークプロトコルスタック群との間に、
79 統一的なインターフェースを提供するものである。
80 プロトコルモジュールは
81 .I "プロトコルファミリー (protocol familiy)"
82 (例:
83 .BR AF_INET ", " AF_IPX ", " AF_PACKET )
84
85 .I "ソケットタイプ (socket types)"
86 (例:
87 .BR SOCK_STREAM ", " SOCK_DGRAM )
88 に分類できる。
89 これらに関するより詳しい情報は
90 .BR socket (2)
91 を参照のこと。
92 .\"O .SS Socket Layer Functions
93 .SS ソケット層の関数群
94 .\"O These functions are used by the user process to send or receive packets
95 .\"O and to do other socket operations.
96 .\"O For more information see their respective manual pages.
97 これらの関数はユーザプロセスがパケットを送受信したり、その他のソケット操作を
98 行ったりするために用いられる。詳細はそれぞれのマニュアルページを
99 見てほしい。
100
101 .\"O .BR socket (2)
102 .\"O creates a socket,
103 .\"O .BR connect (2)
104 .\"O connects a socket to a remote socket address,
105 .\"O the
106 .\"O .BR bind (2)
107 .\"O function binds a socket to a local socket address,
108 .\"O .BR listen (2)
109 .\"O tells the socket that new connections shall be accepted, and
110 .\"O .BR accept (2)
111 .\"O is used to get a new socket with a new incoming connection.
112 .\"O .BR socketpair (2)
113 .\"O returns two connected anonymous sockets (only implemented for a few
114 .\"O local families like
115 .\"O .BR AF_UNIX )
116 .BR socket (2)
117 はソケットを生成する。
118 .BR connect (2)
119 はソケットをリモートのソケットアドレスに接続する。
120 .BR bind (2)
121 はソケットをローカルのソケットアドレスにバインドする。
122 .BR listen (2)
123 はソケットに新しい接続が来たら受信するように伝え、
124 .BR accept (2)
125 は外部からやってきた接続に対して新しいソケットを得るために用いられる。
126 .BR socketpair (2)
127 は互いに接続された二つの名前無しソケット (anonymous socket) を返す
128 .RB ( AF_UNIX
129 のような、いくつかのローカルなファミリーでしか実装されていない)。
130 .PP
131 .\"O .BR send (2),
132 .\"O .BR sendto (2),
133 .\"O and
134 .\"O .BR sendmsg (2)
135 .\"O send data over a socket, and
136 .\"O .BR recv (2),
137 .\"O .BR recvfrom (2),
138 .\"O .BR recvmsg (2)
139 .\"O receive data from a socket.
140 .\"O .BR poll (2)
141 .\"O and
142 .\"O .BR select (2)
143 .\"O wait for arriving data or a readiness to send data.
144 .\"O In addition, the standard I/O operations like
145 .\"O .BR write (2),
146 .\"O .BR writev (2),
147 .\"O .BR sendfile (2),
148 .\"O .BR read (2),
149 .\"O and
150 .\"O .BR readv (2)
151 .\"O can be used to read and write data.
152 .BR send (2),
153 .BR sendto (2),
154 .BR sendmsg (2)
155 はソケットを通してデータを送信し、
156 .BR recv (2)
157 .BR recvfrom (2),
158 .BR recvmsg (2)
159 はソケットからデータを受信する。
160 .BR poll (2)
161
162 .BR select (2)
163 はデータの到着を待ったり、データ送信の準備ができるまで待ったりする。
164 さらに、
165 .BR write (2),
166 .BR writev (2),
167 .BR sendfile (2),
168 .BR read (2),
169 .BR readv (2)
170 のような標準的な I/O 操作もデータの読み書きに用いることができる。
171 .PP
172 .\"O .BR getsockname (2)
173 .\"O returns the local socket address and
174 .\"O .BR getpeername (2)
175 .\"O returns the remote socket address.
176 .\"O .BR getsockopt (2)
177 .\"O and
178 .\"O .BR setsockopt (2)
179 .\"O are used to set or get socket layer or protocol options.
180 .\"O .BR ioctl (2)
181 .\"O can be used to set or read some other options.
182 .BR getsockbyname (2)
183 はローカルのソケットアドレスを返し、
184 .BR getpeername (2)
185 はリモートのソケットアドレスを返す。
186 .BR getsockopt (2)
187
188 .BR setsockopt (2)
189 はソケット層のオプションやプロトコルオプションの取得・設定に用いられる。
190 他のいくつかのオプションの取得・設定には
191 .BR ioctl (2)
192 を使うことができる。
193 .PP
194 .\"O .BR close (2)
195 .\"O is used to close a socket.
196 .\"O .BR shutdown (2)
197 .\"O closes parts of a full-duplex socket connection.
198 .BR close (2)
199 はソケットをクローズする。
200 .BR shutdown (2)
201 は全二重なソケット接続を部分的にクローズする。
202 .PP
203 .\"O Seeking, or calling
204 .\"O .BR pread (2)
205 .\"O or
206 .\"O .BR pwrite (2)
207 .\"O with a nonzero position is not supported on sockets.
208 シーク動作や、 0 以外の位置に対する
209 .BR pread (2)
210
211 .BR pwrite (2)
212 はソケットではサポートされていない。
213 .PP
214 .\"O It is possible to do nonblocking I/O on sockets by setting the
215 .\"O .B O_NONBLOCK
216 .\"O flag on a socket file descriptor using
217 .\"O .BR fcntl (2).
218 .\"O Then all operations that would block will (usually)
219 .\"O return with
220 .\"O .B EAGAIN
221 .\"O (operation should be retried later);
222 非ブロッキングな I/O をソケットで行うことは可能で、
223 .BR fcntl (2)
224 を使ってソケットのファイルディスクリプタに
225 .B O_NONBLOCK
226 フラグをセットすれば良い。
227 こうするとブロックされる操作は、 (通常)
228 .B EAGAIN
229 エラーで戻ることになる
230 (後で処理が再試行されることが期待されている)。
231 .\"O .BR connect (2)
232 .\"O will return
233 .\"O .B EINPROGRESS
234 .\"O error.
235 .BR connect (2)
236 では
237 .B EINPROGRESS
238 エラーが返される。
239 .\"O The user can then wait for various events via
240 .\"O .BR poll (2)
241 .\"O or
242 .\"O .BR select (2).
243 この場合、ユーザはさまざまなイベントを
244 .BR poll (2)
245
246 .BR select (2)
247 を使って待つことができる。
248 .TS
249 tab(:) allbox;
250 c s s
251 l l l.
252 .\"O I/O events
253 I/O イベント
254 .\"O Event:Poll flag:Occurrence
255 イベント:poll フラグ:内容
256 .\"O Read:POLLIN:T{
257 .\"O New data arrived.
258 .\"O T}
259 Read:POLLIN:T{
260 新しいデータが到着した。
261 T}
262 .\"O Read:POLLIN:T{
263 .\"O A connection setup has been completed
264 .\"O (for connection-oriented sockets)
265 .\"O T}
266 Read:POLLIN:T{
267 (接続志向のソケットで)
268 接続の設定が終了した。
269 T}
270 .\"O Read:POLLHUP:T{
271 .\"O A disconnection request has been initiated by the other end.
272 .\"O T}
273 Read:POLLHUP:T{
274 接続先で切断要求が生成された。
275 T}
276 .\"O Read:POLLHUP:T{
277 .\"O A connection is broken (only for connection-oriented protocols).
278 .\"O When the socket is written
279 .\"O .B SIGPIPE
280 .\"O is also sent.
281 .\"O T}
282 Read:POLLHUP:T{
283 接続が壊れた (接続志向のプロトコルのみ)。
284 この場合、ソケットに書き込みが行われると
285 .B SIGPIPE
286 も送信される。
287 T}
288 .\"O Write:POLLOUT:T{
289 .\"O Socket has enough send buffer space for writing new data.
290 .\"O T}
291 Write:POLLOUT:T{
292 ソケットには新しいデータを書き込むのに
293 充分なバッファ領域がある。
294 T}
295 .\"O Read/Write:T{
296 .\"O POLLIN|
297 .\"O .br
298 .\"O POLLOUT
299 .\"O T}:T{
300 .\"O An outgoing
301 .\"O .BR connect (2)
302 .\"O finished.
303 .\"O T}
304 Read/Write:T{
305 POLLIN|
306 .br
307 POLLOUT
308 T}:T{
309 外部向けの
310 .BR connect (2)
311 が終了した。
312 T}
313 .\"O Read/Write:POLLERR:An asynchronous error occurred.
314 Read/Write:POLLERR:T{
315 非同期的 (asynchronous) なエラーが起こった。
316 T}
317 .\"O Read/Write:POLLHUP:The other end has shut down one direction.
318 Read/Write:POLLHUP:接続先が片方向を切断した。
319 .\"O Exception:POLLPRI:T{
320 .\"O Urgent data arrived.
321 .\"O .B SIGURG
322 .\"O is sent then.
323 .\"O T}
324 Exception:POLLPRI:T{
325 緊急データ (urgent data) が到着した。
326 この場合は
327 .B SIGURG
328 が送信される。
329 T}
330 .\" FIXME . The following is not true currently:
331 .\" It is no I/O event when the connection
332 .\" is broken from the local end using
333 .\" .BR shutdown (2)
334 .\" or
335 .\" .BR close (2).
336 .TE
337
338 .PP
339 .\"O An alternative to
340 .\"O .BR poll (2)
341 .\"O and
342 .\"O .BR select (2)
343 .\"O is to let the kernel inform the application about events
344 .\"O via a
345 .\"O .B SIGIO
346 .\"O signal.
347 .\"O For that the
348 .\"O .B O_ASYNC
349 .\"O flag must be set on a socket file descriptor via
350 .\"O .BR fcntl (2)
351 .\"O and a valid signal handler for
352 .\"O .B SIGIO
353 .\"O must be installed via
354 .\"O .BR sigaction (2).
355 .\"O See the
356 .\"O .I Signals
357 .\"O discussion below.
358 .BR poll (2)
359
360 .BR select (2)
361 を使う代わりに、カーネルからアプリケーションに
362 イベントを通知させるのに
363 .B SIGIO
364 シグナルを使う方法もある。
365 この方法を使うには、
366 .BR fcntl (2)
367 を用いてソケットのファイルディスクリプタに
368 .B O_ASYNC
369 フラグをセットし、
370 .B SIGIO
371 に対する有効なシグナルハンドラを
372 .BR sigaction (2)
373 によって設定しておく必要がある。
374 後述の
375 .I シグナル
376 に関する議論も参考にすること。
377 .\"O .SS Socket Options
378 .SS ソケットオプション
379 .\"O These socket options can be set by using
380 .\"O .BR setsockopt (2)
381 .\"O and read with
382 .\"O .BR getsockopt (2)
383 .\"O with the socket level set to
384 .\"O .B SOL_SOCKET
385 .\"O for all sockets:
386 これらのソケットオプションは、
387 .BR setsockopt (2)
388 を用いれば設定でき、
389 .BR getsockopt (2)
390 を用いれば取得できる。
391 但し、どのソケットの場合も
392 ソケットレベルには
393 .B SOL_SOCKET
394 を指定すること。
395 .\"O .\" SO_ACCEPTCONN is in POSIX.1-2001, and its origin is explained in
396 .\"O .\" W R Stevens, UNPv1
397 .\" SO_ACCEPTCONN は POSIX.1-2001 で定義されており、元は
398 .\" W R Stevens の UNPv1 に書かれていた。
399 .TP
400 .B SO_ACCEPTCONN
401 .\"O Returns a value indicating whether or not this socket has been marked
402 .\"O to accept connections with
403 .\"O .BR listen (2).
404 .\"O The value 0 indicates that this is not a listening socket,
405 .\"O the value 1 indicates that this is a listening socket.
406 .\"O Can only be read
407 .\"O with
408 .\"O .BR getsockopt (2).
409 このソケットが
410 .BR listen (2)
411 によって接続待ち受け状態に設定されているかどうかを示す値を返す。
412 値 0 は listen 状態のソケットでないことを、
413 値 1 は listen 状態のソケットであることを示す。
414 .BR getsockopt (2)
415 からのみ読み出し可能である。
416 .TP
417 .B SO_BINDTODEVICE
418 .\"O Bind this socket to a particular device like \(lqeth0\(rq,
419 .\"O as specified in the passed interface name.
420 .\"O If the
421 .\"O name is an empty string or the option length is zero, the socket device
422 .\"O binding is removed.
423 .\"O The passed option is a variable-length null-terminated
424 .\"O interface name string with the maximum size of
425 .\"O .BR IFNAMSIZ .
426 このソケットを、引き数で渡したインターフェース名で指定される
427 (\(lqeth0\(rq のような) 特定のデバイスにバインドする。
428 名前が空文字列だったり、オプションの長さ (optlen) が 0 の場合には、
429 ソケットのバインドが削除される。渡すオプションは、インターフェース名が
430 入ったヌル文字で終端された可変長の文字列である。
431 文字列の最大のサイズは
432 .B IFNAMSIX
433 である。
434 .\"O If a socket is bound to an interface,
435 .\"O only packets received from that particular interface are processed by the
436 .\"O socket.
437 .\"O Note that this only works for some socket types, particularly
438 .\"O .B AF_INET
439 .\"O sockets.
440 .\"O It is not supported for packet sockets (use normal
441 .\"O .BR bind (8)
442 .\"O there).
443 ソケットがインターフェースにバインドされると、
444 その特定のインターフェースから受信されたパケットだけを処理する。
445 このオプションはいくつかのソケットタイプ、特に
446 .B AF_INET
447 に対してのみ動作する点に注意すること。
448 パケットソケットではサポートされていない (通常の
449 .BR bind (8)
450 を使うこと)。
451 .TP
452 .B SO_BROADCAST
453 .\"O Set or get the broadcast flag.
454 .\"O When enabled, datagram sockets
455 .\"O receive packets sent to a broadcast address and they are allowed to send
456 .\"O packets to a broadcast address.
457 .\"O This option has no effect on stream-oriented sockets.
458 ブロードキャストフラグを設定・取得する。有効になっていると、
459 データグラムソケットはブロードキャストアドレスに送られたパケットを受信したり、
460 ブロードキャストアドレスにパケットを送信したりできるようになる。
461 ストリーム指向のソケットには何の効果もない。
462 .TP
463 .B SO_BSDCOMPAT
464 .\"O Enable BSD bug-to-bug compatibility.
465 .\"O This is used by the UDP protocol module in Linux 2.0 and 2.2.
466 .\"O If enabled ICMP errors received for a UDP socket will not be passed
467 .\"O to the user program.
468 .\"O In later kernel versions, support for this option has been phased out:
469 .\"O Linux 2.4 silently ignores it, and Linux 2.6 generates a kernel warning
470 .\"O (printk()) if a program uses this option.
471 .\"O Linux 2.0 also enabled BSD bug-to-bug compatibility
472 .\"O options (random header changing, skipping of the broadcast flag) for raw
473 .\"O sockets with this option, but that was removed in Linux 2.2.
474 BSD のバグに対して互換性を取るための機能を有効にする。
475 この機能は Linux 2.0 と 2.2 の UDP プロトコルモジュールで使用されている。
476 有効になっていると、 UDP ソケットで受信された ICMP エラーは
477 ユーザプログラムに渡されない。
478 これ以降のバージョンのカーネルでは、このオプションのサポートは
479 段階的に廃止されてきた。
480 Linux 2.4 ではこのオプションは黙って無視され、
481 Linux 2.6 ではプログラムがこのオプションを使用すると (printk() を使って)
482 カーネルの警告メッセージが出力される。
483 Linux 2.0 では、このオプションを指定すると、
484 raw ソケットにおいても BSD のバグ (ランダムヘッダ変更、
485 ブロードキャストフラグのスキップ)
486 に対する互換機能が有効になっていた。
487 しかし、こちらは Linux 2.2 で削除された。
488 .TP
489 .B SO_DEBUG
490 .\"O Enable socket debugging.
491 .\"O Only allowed for processes with the
492 .\"O .B CAP_NET_ADMIN
493 .\"O capability or an effective user ID of 0.
494 ソケットのデバッグ機能を有効にする。
495 .B CAP_NET_ADMIN
496 権限を持つプロセスか、実効ユーザ ID が 0 のプロセスでしか
497 利用できない。
498 .TP
499 .B SO_ERROR
500 .\"O Get and clear the pending socket error.
501 .\"O Only valid as a
502 .\"O .BR getsockopt (2).
503 .\"O Expects an integer.
504 保留になっていたソケットエラーを取得してクリアする。
505 .BR getsockopt (2)
506 でのみ用いることができる。
507 整数値をとる。
508 .TP
509 .B SO_DONTROUTE
510 .\"O Don't send via a gateway, only send to directly connected hosts.
511 .\"O The same effect can be achieved by setting the
512 .\"O .B MSG_DONTROUTE
513 .\"O flag on a socket
514 .\"O .BR send (2)
515 .\"O operation.
516 .\"O Expects an integer boolean flag.
517 ゲートウェイを経由せず、直接接続されているホストに送信する。
518 .BR send (2)
519 操作で
520 .B MSG_DONTROUTE
521 フラグをセットした場合も同じ効果が得られる。
522 ブール整数のフラグを取る。
523 .TP
524 .B SO_KEEPALIVE
525 .\"O Enable sending of keep-alive messages on connection-oriented sockets.
526 .\"O Expects an integer boolean flag.
527 接続志向のソケットに対する keep-alive メッセージの送信を有効にする。
528 ブール値の整数フラグをとる。
529 .TP
530 .B SO_LINGER
531 .\"O Sets or gets the
532 .\"O .B SO_LINGER
533 .\"O option.
534 .\"O The argument is a
535 .\"O .I linger
536 .\"O structure.
537 .B SO_LINGER
538 オプションを取得・設定する。引き数には
539 .I linger
540 構造体を取る。
541 .sp
542 .in +4n
543 .nf
544 struct linger {
545     int l_onoff;    /* linger active */
546     int l_linger;   /* how many seconds to linger for */
547 };
548 .fi
549 .in
550 .IP
551 .\"O When enabled, a
552 .\"O .BR close (2)
553 .\"O or
554 .\"O .BR shutdown (2)
555 .\"O will not return until all queued messages for the socket have been
556 .\"O successfully sent or the linger timeout has been reached.
557 .\"O Otherwise,
558 .\"O the call returns immediately and the closing is done in the background.
559 .\"O When the socket is closed as part of
560 .\"O .BR exit (2),
561 .\"O it always lingers in the background.
562 有効になっていると、
563 .BR close (2)
564
565 .BR shutdown (2)
566 は、そのソケットにキューイングされたメッセージがすべて送信完了するか、
567 linger (居残り) タイムアウトになるまで返らない。無効になっていると、
568 これらのコールはただちに戻り、クローズ動作はバックグラウンドで行われる。
569 ソケットのクローズを
570 .BR exit (2)
571 の一部として行った場合には、残っているソケットの
572 クローズ動作は必ずバックグラウンドに送られる。
573 .TP
574 .B SO_OOBINLINE
575 .\"O If this option is enabled,
576 .\"O out-of-band data is directly placed into the receive data stream.
577 .\"O Otherwise out-of-band data is only passed when the
578 .\"O .B MSG_OOB
579 .\"O flag is set during receiving.
580 このオプションを有効にすると、帯域外データ (out-of-band data) は
581 受信データストリーム中に置かれる。有効にしなければ、
582 帯域外データは受信時に
583 .B MSG_OOB
584 フラグがセットされている場合に限って渡される。
585 .\"O .\" don't document it because it can do too much harm.
586 .\"O .\".B SO_NO_CHECK
587 .\" あまりに危険なことができるので、このオプションについては記載しないこと。
588 .\".B SO_NO_CHECK
589 .TP
590 .B SO_PASSCRED
591 .\"O Enable or disable the receiving of the
592 .\"O .B SCM_CREDENTIALS
593 .\"O control message.
594 .\"O For more information see
595 .\"O .BR unix (7).
596 .B SCM_CREDENTIALS
597 制御メッセージの受信を有効/無効にする。詳細は
598 .BR unix (7)
599 を参照のこと。
600 .\" FIXME Document SO_PASSSEC, added in 2.6.18; there is some info
601 .\" in the 2.6.18 ChangeLog
602 .TP
603 .B SO_PEERCRED
604 .\"O Return the credentials of the foreign process connected to this socket.
605 .\"O This is only possible for connected
606 .\"O .B AF_UNIX
607 .\"O stream sockets and
608 .\"O .B AF_UNIX
609 .\"O stream and datagram socket pairs created using
610 .\"O .BR socketpair (2);
611 .\"O see
612 .\"O .BR unix (7).
613 このソケットに接続してきた外部プロセスの信任状 (credential) を返す。
614 このソケットオプションが利用できるのは、
615 接続された
616 .B AF_UNIX
617 ストリームソケット間、および
618 .BR socketpair (2)
619 を使って作成された
620 .B AF_UNIX
621 のストリームソケットとデータグラムソケットのペアだけである。
622 .BR unix (7)
623 を参照のこと。
624 .\"O The returned credentials are those that were in effect at the time
625 .\"O of the call to
626 .\"O .BR connect (2)
627 .\"O or
628 .\"O .BR socketpair (2).
629 .\"O Argument is a
630 .\"O .I ucred
631 .\"O structure.
632 .\"O Only valid as a
633 .\"O .BR getsockopt (2).
634 .BR connect (2)
635
636 .BR socketpair (2)
637 が呼ばれた時に有効であった信任状が返される。
638 引き数は
639 .I ucred
640 構造体である。
641 .BR getsockopt (2)
642 でのみ用いることができる。
643 .TP
644 .B SO_PRIORITY
645 .\"O Set the protocol-defined priority for all packets to be sent on
646 .\"O this socket.
647 .\"O Linux uses this value to order the networking queues:
648 .\"O packets with a higher priority may be processed first depending
649 .\"O on the selected device queueing discipline.
650 .\"O For
651 .\"O .BR ip (7),
652 .\"O this also sets the IP type-of-service (TOS) field for outgoing packets.
653 .\"O Setting a priority outside the range 0 to 6 requires the
654 .\"O .B CAP_NET_ADMIN
655 .\"O capability.
656 プロトコルで定義された優先度を、このソケットから
657 送信される全てのパケットにセットする。 Linux はネットワークキュー内部の
658 整列にこの値を用いる。高い優先度を持っているパケットは先に処理される。
659 ただしそのデバイスのキュー処理のやり方に依存する。
660 .BR ip (7)
661 では、外向けパケットの IP type-of-service (TOS) フィールドにもこの値が設定される。
662 0 から 6 以外の優先度をセットするには
663 .B CAP_NET_ADMIN
664 ケーパビリティが必要である。
665 .TP
666 .B SO_RCVBUF
667 .\"O Sets or gets the maximum socket receive buffer in bytes.
668 .\"O The kernel doubles this value (to allow space for bookkeeping overhead)
669 .\"O when it is set using
670 .\"O .\" Most (all?) other implementations do not do this -- MTK, Dec 05
671 .\"O .BR setsockopt (2),
672 .\"O and this doubled value is returned by
673 .\"O .BR getsockopt (2).
674 .\"O The default value is set by the
675 .\"O .I /proc/sys/net/core/rmem_default
676 .\"O file, and the maximum allowed value is set by the
677 .\"O .I /proc/sys/net/core/rmem_max
678 .\"O file.
679 .\"O The minimum (doubled) value for this option is 256.
680 ソケットの受信バッファの最大サイズを設定・取得する (バイト単位)。
681 .BR setsockopt (2)
682 を使って値が設定されたときに (管理オーバヘッド用の領域を確保するために)
683 カーネルはこの値を 2倍し、
684 .\" 他のほとんどの (全ての?) 実装ではこんなことは行っていない -- MTK, Dec 05
685 .BR getsockopt (2)
686 はこの 2倍された値を返す。
687 デフォルトの値は
688 .I /proc/sys/net/core/rmem_default
689 ファイルで設定され、許容される最大の値は
690 .I /proc/sys/net/core/rmem_max
691 ファイルで設定される。
692 このオプションの最小値は (2倍した値で) 256 である。
693 .TP
694 .\"O .BR SO_RCVBUFFORCE " (since Linux 2.6.14)"
695 .BR SO_RCVBUFFORCE " (Linux 2.6.14 以降)"
696 .\"O Using this socket option, a privileged
697 .\"O .RB ( CAP_NET_ADMIN )
698 .\"O process can perform the same task as
699 .\"O .BR SO_RCVBUF ,
700 .\"O but the
701 .\"O .I rmem_max
702 .\"O limit can be overridden.
703 このソケットオプションを使うと、特権プロセス
704 .RB ( CAP_NET_ADMIN
705 を持つプロセス) は
706 .B SO_RCVBUF
707 と同じことを実行できる。
708 ただし、上限
709 .I rmem_max
710 を上書きすることができる。
711 .TP
712 .\"O .BR SO_RCVLOWAT " and " SO_SNDLOWAT
713 .BR SO_RCVLOWAT " と " SO_SNDLOWAT
714 .\"O Specify the minimum number of bytes in the buffer until the socket layer
715 .\"O will pass the data to the protocol
716 .\"O .RB ( SO_SNDLOWAT )
717 .\"O or the user on receiving
718 .\"O .RB ( SO_RCVLOWAT ).
719 .\"O These two values are initialized to 1.
720 .\"O .B SO_SNDLOWAT
721 .\"O is not changeable on Linux
722 .\"O .RB ( setsockopt (2)
723 .\"O fails with the error
724 .\"O .BR ENOPROTOOPT ).
725 .\"O .B SO_RCVLOWAT
726 .\"O is changeable
727 .\"O only since Linux 2.4.
728 バッファ中に溜めることのできるデータの最小値を指定する。
729 このサイズを越えると、ソケット層はそのデータをプロトコルに渡し
730 .RB ( SO_SNDLOWAT )、
731 受信時にはユーザに渡す
732 .RB ( SO_RCVLOWAT )。
733 これら二つの値は 1 に初期化される。
734 .B SO_SNDLOWAT
735 は Linux では変更できない
736 .RB ( setsockopt (2)
737
738 .B ENOPROTOOPT
739 エラーで失敗する)。
740 .B SO_RCVLOWAT
741 は Linux 2.4 以降でのみ変更可能である。
742 .\"O The
743 .\"O .BR select (2)
744 .\"O and
745 .\"O .BR poll (2)
746 .\"O system calls currently do not respect the
747 .\"O .B SO_RCVLOWAT
748 .\"O setting on Linux,
749 .\"O and mark a socket readable when even a single byte of data is available.
750 .\"O A subsequent read from the socket will block until
751 .\"O .B SO_RCVLOWAT
752 .\"O bytes are available.
753 .\"O .\" See http://marc.theaimsgroup.com/?l=linux-kernel&m=111049368106984&w=2
754 .\"O .\" Tested on kernel 2.6.14 -- mtk, 30 Nov 05
755 現状、Linux ではシステムコール
756 .BR select (2)
757
758 .BR poll (2)
759
760 .B SO_RCVLOWAT
761 の設定を考慮に入れずに動作し、
762 データが1バイト利用可能になっただけでも、
763 ソケットは読み出し可能とのマークをつける。
764 一方、それに続けて行うソケットからの read は
765 .B SO_RCVLOWAT
766 バイトのデータが利用可能になるまで停止してしまう。
767 .\" See http://marc.theaimsgroup.com/?l=linux-kernel&m=111049368106984&w=2
768 .\" Tested on kernel 2.6.14 -- mtk, 30 Nov 05
769 .TP
770 .\"O .BR SO_RCVTIMEO " and " SO_SNDTIMEO
771 .BR SO_RCVTIMEO " と " SO_SNDTIMEO
772 .\"O .\" Not implemented in 2.0.
773 .\"O .\" Implemented in 2.1.11 for getsockopt: always return a zero struct.
774 .\"O .\" Implemented in 2.3.41 for setsockopt, and actually used.
775 .\" 2.0 では実装されていない。
776 .\" getsockopt については 2.1.11 で実装された。常に 0 の構造体を返す。
777 .\" setsockopt については 2.3.41 で実装され、実際に使われている。
778 .\"O Specify the receiving or sending timeouts until reporting an error.
779 .\"O The argument is a
780 .\"O .IR "struct timeval" .
781 .\"O If an input or output function blocks for this period of time, and
782 .\"O data has been sent or received, the return value of that function
783 .\"O will be the amount of data transferred; if no data has been transferred
784 .\"O and the timeout has been reached then \-1 is returned with
785 .\"O .I errno
786 .\"O set to
787 .\"O .B EAGAIN
788 .\"O or
789 .\"O .B EWOULDBLOCK
790 .\"O .\" in fact to EAGAIN
791 .\"O just as if the socket was specified to be nonblocking.
792 .\"O If the timeout is set to zero (the default)
793 .\"O then the operation will never timeout.
794 送信・受信のタイムアウトを指定する。これを越えるとエラーを報告する。
795 引き数は
796 .I "struct timeval"
797 である。
798 入出力関数がタイムアウト時間の間ブロックされ、かつデータの送信または
799 受信が行われていた場合は、転送されたデータ量が関数の返り値となる。
800 何もデータが転送されずにタイムアウトに達した場合は、
801 \-1 を返し、
802 .I errno
803
804 .B EAGAIN
805
806 .B EWOULDBLOCK
807 を設定され、
808 .\" 実際には EAGAIN が設定される
809 あたかもソケットに非ブロッキングが指定されたように見える。
810 タイムアウト値に (デフォルト値である) 0 に設定すると、
811 操作は決してタイムアウトしなくなる。
812 .\"O Timeouts only have effect for system calls that perform socket I/O (e.g.,
813 .\"O .BR read (2),
814 .\"O .BR recvmsg (2),
815 .\"O .BR send (2),
816 .\"O .BR sendmsg (2));
817 .\"O timeouts have no effect for
818 .\"O .BR select (2),
819 .\"O .BR poll (2),
820 .\"O .BR epoll_wait (2),
821 .\"O etc.
822 タイムアウトが影響を及ぼすのは、
823 ソケット I/O を実行するシステムコールだけ
824 (例えば
825 .BR read (2),
826 .BR recvmsg (2),
827 .BR send (2),
828 .BR sendmsg (2))
829 である。
830 .BR select (2),
831 .BR poll (2),
832 .BR epoll_wait (2)
833 などにはタイムアウトは影響を及ぼさない。
834 .TP
835 .B SO_REUSEADDR
836 .\"O Indicates that the rules used in validating addresses supplied in a
837 .\"O .BR bind (2)
838 .\"O call should allow reuse of local addresses.
839 .\"O For
840 .\"O .B AF_INET
841 .\"O sockets this
842 .\"O means that a socket may bind, except when there
843 .\"O is an active listening socket bound to the address.
844 .\"O When the listening socket is bound to
845 .\"O .B INADDR_ANY
846 .\"O with a specific port then it is not possible
847 .\"O to bind to this port for any local address.
848 .\"O Argument is an integer boolean flag.
849 .BR bind (2)
850 コールに与えられたアドレスが正しいかを判断するルールで、
851 ローカルアドレスの再利用を可能にする。
852 つまり
853 .B AF_INET
854 ソケットなら、そのアドレスにバインドされたアクティブな listen
855 状態のソケットが存在しない限り、バインドが行える。
856 listen 状態のソケットがアドレス
857 .B INADDR_ANY
858 で特定のポートにバインドされている場合には、
859 このポートに対しては、どんなローカルアドレスでもバインドできない。
860 引き数はブール整数のフラグである。
861 .TP
862 .B SO_SNDBUF
863 .\"O Sets or gets the maximum socket send buffer in bytes.
864 .\"O The kernel doubles this value (to allow space for bookkeeping overhead)
865 .\"O when it is set using
866 .\"O .\" Most (all?) other implementations do not do this -- MTK, Dec 05
867 .\"O .BR setsockopt (2),
868 .\"O and this doubled value is returned by
869 .\"O .BR getsockopt (2).
870 .\"O The default value is set by the
871 .\"O .I /proc/sys/net/core/wmem_default
872 .\"O file and the maximum allowed value is set by the
873 .\"O .I /proc/sys/net/core/wmem_max
874 .\"O file.
875 .\"O The minimum (doubled) value for this option is 2048.
876 ソケットの送信バッファの最大サイズを設定・取得する (バイト単位)。
877 .BR setsockopt (2)
878 を使って値が設定されたときに (管理オーバヘッド用の領域を確保するために)
879 カーネルはこの値を 2倍し、
880 .\" 他のほとんどの (全ての?) 実装ではこんなことは行っていない -- MTK, Dec 05
881 .BR getsockopt (2)
882 はこの 2倍された値を返す。
883 デフォルトの値は
884 .I /proc/sys/net/core/wmem_default
885 ファイルで設定され、許容される最大の値は
886 .I /proc/sys/net/core/wmem_max
887 ファイルで設定される。
888 このオプションの最小値は (2倍した値で) 2048 である。
889 .TP
890 .\"O .BR SO_SNDBUFFORCE " (since Linux 2.6.14)"
891 .BR SO_SNDBUFFORCE " (Linux 2.6.14 以降)"
892 .\"O Using this socket option, a privileged
893 .\"O .RB ( CAP_NET_ADMIN )
894 .\"O process can perform the same task as
895 .\"O .BR SO_SNDBUF ,
896 .\"O but the
897 .\"O .I wmem_max
898 .\"O limit can be overridden.
899 このソケットオプションを使うと、特権プロセス
900 .RB ( CAP_NET_ADMIN
901 を持つプロセス) は
902 .B SO_SNDBUF
903 と同じことを実行できる。
904 ただし、上限
905 .I wmem_max
906 を上書きすることができる。
907 .TP
908 .B SO_TIMESTAMP
909 .\"O Enable or disable the receiving of the
910 .\"O .B SO_TIMESTAMP
911 .\"O control message.
912 .\"O The timestamp control message is sent with level
913 .\"O .B SOL_SOCKET
914 .\"O and the
915 .\"O .I cmsg_data
916 .\"O field is a
917 .\"O .I "struct timeval"
918 .\"O indicating the
919 .\"O reception time of the last packet passed to the user in this call.
920 .\"O See
921 .\"O .BR cmsg (3)
922 .\"O for details on control messages.
923 .B SO_TIMESTAMP
924 制御メッセージの受信を有効/無効にする。
925 タイムスタンプ制御メッセージはレベル
926 .B SOL_SOCKET
927 で送信され、
928 .I cmsg_data
929 フィールドはこのシステムコールでユーザに渡した
930 最後のパケットの受信時刻を示す
931 .I "struct timeval"
932 である。
933 制御メッセージの詳細については
934 .BR cmsg (3)
935 を参照。
936 .TP
937 .B SO_TYPE
938 .\"O Gets the socket type as an integer (like
939 .\"O .BR SOCK_STREAM ).
940 .\"O Can only be read
941 .\"O with
942 .\"O .BR getsockopt (2).
943 ソケットのタイプを整数で取得する (例:
944 .BR SOCK_STREAM )。
945 .BR getsockopt (2)
946 からのみ読み出し可能である。
947 .\"O .SS Signals
948 .SS シグナル
949 .\"O When writing onto a connection-oriented socket that has been shut down
950 .\"O (by the local or the remote end)
951 .\"O .B SIGPIPE
952 .\"O is sent to the writing process and
953 .\"O .B EPIPE
954 .\"O is returned.
955 .\"O The signal is not sent when the write call
956 .\"O specified the
957 .\"O .B MSG_NOSIGNAL
958 .\"O flag.
959 (ローカルもしくはリモート側で) 切断された
960 接続指向 (connection-oriented) のソケットに対して
961 書き込みを行うと、その書き込みを行ったプロセスに
962 .B SIGPIPE
963 が送られ、
964 .B EPIPE
965 が返される。 write 呼び出しに
966 .B MSG_NOSIGNAL
967 フラグを指定していた場合はシグナルは送られない。
968 .PP
969 .\"O When requested with the
970 .\"O .B FIOSETOWN
971 .\"O .BR fcntl (2)
972 .\"O or
973 .\"O .B SIOCSPGRP
974 .\"O .BR ioctl (2),
975 .\"O .B SIGIO
976 .\"O is sent when an I/O event occurs.
977 .\"O It is possible to use
978 .\"O .BR poll (2)
979 .\"O or
980 .\"O .BR select (2)
981 .\"O in the signal handler to find out which socket the event occurred on.
982 .B FIOSETOWN
983 .BR fcntl (2)
984
985 .B SIOCSPGRP
986 .BR ioctl (2)
987 をプロセスまたはプロセスグループに指定しておくと、
988 I/O イベントが起きたときに
989 .B SIGIO
990 が送られる。
991 .BR poll (2)
992
993 .BR select (2)
994 をシグナルハンドラ内で用いれば、どのソケットでイベントが起こったかを
995 知ることができる。
996 .\"O An alternative (in Linux 2.2) is to set a real-time signal using the
997 .\"O .B F_SETSIG
998 .\"O .BR fcntl (2);
999 .\"O the handler of the real time signal will be called with
1000 .\"O the file descriptor in the
1001 .\"O .I si_fd
1002 .\"O field of its
1003 .\"O .IR siginfo_t .
1004 .\"O See
1005 .\"O .BR fcntl (2)
1006 .\"O for more information.
1007 (Linux 2.2 における) 別の方法としては、
1008 .B F_SETSIG
1009 .BR fcntl (2)
1010 を用いてリアルタイムシグナルを設定するやり方もある。
1011 リアルタイムシグナルのハンドラは、
1012 .I siginfo_t
1013
1014 .I si_fd
1015 フィールドにファイルディスクリプタが入った状態で呼び出される。
1016 詳細は
1017 .BR fcntl (2)
1018 を参照のこと。
1019 .PP
1020 .\"O Under some circumstances (e.g., multiple processes accessing a
1021 .\"O single socket), the condition that caused the
1022 .\"O .B SIGIO
1023 .\"O may have already disappeared when the process reacts to the signal.
1024 .\"O If this happens, the process should wait again because Linux
1025 .\"O will resend the signal later.
1026 状況によっては (例えば複数のプロセスが一つのソケットにアクセスしているなど)、
1027 .B SIGIO
1028 の原因となった状態は、プロセスがそのシグナルへの対応を行ったときには
1029 消えてしまっているかもしれない。
1030 この場合は、プロセスは再び待つようにすべきである。
1031 Linux は同じシグナルを後で再送するからである。
1032 .\" .SS Ancillary Messages
1033 .\"O .SS /proc interfaces
1034 .SS /proc インタフェース
1035 .\"O The core socket networking parameters can be accessed
1036 .\"O via files in the directory
1037 .\"O .IR /proc/sys/net/core/ .
1038 core のソケットのネットワーキングパラメータには、
1039 .I /proc/sys/net/core/
1040 ディレクトリ内のファイルを通してアクセスできる。
1041 .TP
1042 .I rmem_default
1043 .\"O contains the default setting in bytes of the socket receive buffer.
1044 ソケットの受信バッファサイズのデフォルト値 (バイト単位)。
1045 .TP
1046 .I rmem_max
1047 .\"O contains the maximum socket receive buffer size in bytes which a user may
1048 .\"O set by using the
1049 .\"O .B SO_RCVBUF
1050 .\"O socket option.
1051 .B SO_RCVBUF
1052 ソケットオプションを用いてユーザが設定できる
1053 ソケットの受信バッファサイズの最大値 (バイト単位)。
1054 .TP
1055 .I wmem_default
1056 .\"O contains the default setting in bytes of the socket send buffer.
1057 ソケットの送信バッファサイズのデフォルト値 (バイト単位)。
1058 .TP
1059 .I wmem_max
1060 .\"O contains the maximum socket send buffer size in bytes which a user may
1061 .\"O set by using the
1062 .\"O .B SO_SNDBUF
1063 .\"O socket option.
1064 .B SO_SNDBUF
1065 ソケットオプションを用いてユーザが設定できる
1066 ソケットの送信バッファサイズの最大値 (バイト単位)。
1067 .TP
1068 .\"O .IR message_cost " and " message_burst
1069 .IR message_cost " と " message_burst
1070 .\"O configure the token bucket filter used to load limit warning messages
1071 .\"O caused by external network events.
1072 トークン・バケット・フィルターを設定する。
1073 これは外部のネットワークイベントによって引き起こされた
1074 負荷限界の警告メッセージに用いられる。
1075 .\"NAKANO "load limit" だと思うんだけど...
1076 .TP
1077 .I netdev_max_backlog
1078 .\"O Maximum number of packets in the global input queue.
1079 グローバルな入力キューにおける最大のパケット数。
1080 .TP
1081 .I optmem_max
1082 .\"O Maximum length of ancillary data and user control data like the iovecs
1083 .\"O per socket.
1084 ソケットあたりの、補助データ (ancillary data) とユーザ制御データ
1085 (iovecs のようなもの) との和の最大長。
1086 .\" netdev_fastroute is not documented because it is experimental
1087 .\"O .SS Ioctls
1088 .SS ioctl
1089 .\"O These operations can be accessed using
1090 .\"O .BR ioctl (2):
1091 以下に示す操作には
1092 .BR ioctl (2)
1093 を用いてアクセスできる。
1094
1095 .in +4n
1096 .nf
1097 .IB error " = ioctl(" ip_socket ", " ioctl_type ", " &value_result ");"
1098 .fi
1099 .in
1100 .TP
1101 .B SIOCGSTAMP
1102 .\"O Return a
1103 .\"O .I struct timeval
1104 .\"O with the receive timestamp of the last packet passed to the user.
1105 .\"O This is useful for accurate round trip time measurements.
1106 .\"O See
1107 .\"O .BR setitimer (2)
1108 .\"O for a description of
1109 .\"O .IR "struct timeval" .
1110 最後にユーザに渡されたパケットの受信タイムスタンプを
1111 .I struct timeval
1112 に入れて返す。
1113 これは round trip 時間を正確に測りたいときに便利である。
1114 .I struct timeval
1115 の説明は
1116 .BR setitimer (2)
1117 を見てほしい。
1118 .\"
1119 .\"O This ioctl should only be used if the socket option
1120 .\"O .B SO_TIMESTAMP
1121 .\"O is not set on the socket.
1122 .\"O Otherwise, it returns the timestamp of the
1123 .\"O last packet that was received while
1124 .\"O .B SO_TIMESTAMP
1125 .\"O was not set, or it fails if no such packet has been received,
1126 .\"O (i.e.,
1127 .\"O .BR ioctl (2)
1128 .\"O returns \-1 with
1129 .\"O .I errno
1130 .\"O set to
1131 .\"O .BR ENOENT ).
1132 この ioctl は、ソケットオプション
1133 .B SO_TIMESTAMP
1134 がソケットにセットされていない場合にのみ使用すべきである。
1135 さもなければ、この ioctl は
1136 .B SO_TIMESTAMP
1137 がセットされていなかった間に受信した最後のパケットの時刻を返すか、
1138 そのようなパケットを受信していない場合には失敗する
1139 (つまり、
1140 .BR ioctl (2)
1141 は \-1 を返し、
1142 .I errno
1143
1144 .B ENOENT
1145 をセットする)。
1146 .TP
1147 .B SIOCSPGRP
1148 .\"O Set the process or process group to send
1149 .\"O .B SIGIO
1150 .\"O or
1151 .\"O .B SIGURG
1152 .\"O signals
1153 .\"O to when an
1154 .\"O asynchronous I/O operation has finished or urgent data is available.
1155 .\"O The argument is a pointer to a
1156 .\"O .IR pid_t .
1157 .\"O If the argument is positive, send the signals to that process.
1158 .\"O If the
1159 .\"O argument is negative, send the signals to the process group with the ID
1160 .\"O of the absolute value of the argument.
1161 .\"O The process may only choose itself or its own process group to receive
1162 .\"O signals unless it has the
1163 .\"O .B CAP_KILL
1164 .\"O capability or an effective UID of 0.
1165 非同期 I/O 操作の終了時や緊急データの受信時に
1166 .B SIGIO
1167
1168 .B SIGURG
1169 シグナル群を送るプロセスやプロセスグループを設定する。
1170 引き数は
1171 .I pid_t
1172 へのポインタである。
1173 引き数が正だと、そのプロセスにシグナルが送られる。負だと、
1174 引き数の絶対値を ID に持つプロセスグループにシグナルが送られる。
1175 シグナル受信先には、自分自身のプロセス / 自分の所属するプロセスグループ
1176 しか指定できない。但し、
1177 .B CAP_KILL
1178 ケーパビリティを持っている場合、及び実効ユーザ ID が 0 のプロセスの場合は
1179 この限りではない。
1180 .TP
1181 .B FIOASYNC
1182 .\"O Change the
1183 .\"O .B O_ASYNC
1184 .\"O flag to enable or disable asynchronous I/O mode of the socket.
1185 .\"O Asynchronous I/O mode means that the
1186 .\"O .B SIGIO
1187 .\"O signal or the signal set with
1188 .\"O .B F_SETSIG
1189 .\"O is raised when a new I/O event occurs.
1190 .B O_ASYNC
1191 フラグを変更し、ソケットの非同期 (asynchronous) I/O モードを
1192 有効/無効にする。非同期 I/O モードでは、
1193 新しい I/O イベントが起きたときに、
1194 .B SIGIO
1195 シグナルや
1196 .B F_SETSIG
1197 で設定されたシグナル・セットが発行される。
1198 .IP
1199 .\"O Argument is an integer boolean flag.
1200 引き数はブール整数のフラグである。
1201 .\"O (This operation is synonymous with the use of
1202 .\"O .BR fcntl (2)
1203 .\"O to set the
1204 .\"O .B O_ASYNC
1205 .\"O flag.)
1206 (この操作は
1207 .BR fcntl (2)
1208 を使って
1209 .B O_ASYNC
1210 フラグをセットするのと同じ意味である。)
1211 .\"
1212 .TP
1213 .B SIOCGPGRP
1214 .\"O Get the current process or process group that receives
1215 .\"O .B SIGIO
1216 .\"O or
1217 .\"O .B SIGURG
1218 .\"O signals,
1219 .\"O or 0
1220 .\"O when none is set.
1221 .B SIGIO
1222
1223 .B SIGURG
1224 を受信したカレントプロセス・プロセスグループを取得する。
1225 ない場合は 0 が返る。
1226 .PP
1227 .\"O Valid
1228 .\"O .BR fcntl (2)
1229 .\"O operations:
1230 有効な
1231 .BR fcntl (2)
1232 操作:
1233 .TP
1234 .B FIOGETOWN
1235 .\"O The same as the
1236 .\"O .B SIOCGPGRP
1237 .\"O .BR ioctl (2).
1238 .B SIOCGPGRP
1239 .BR ioctl (2)
1240 と同じ。
1241 .TP
1242 .B FIOSETOWN
1243 .\"O The same as the
1244 .\"O .B SIOCSPGRP
1245 .\"O .BR ioctl (2).
1246 .B SIOCSPGRP
1247 .BR ioctl (2)
1248 と同じ。
1249 .\"O .SH VERSIONS
1250 .SH バージョン
1251 .\"O .B SO_BINDTODEVICE
1252 .\"O was introduced in Linux 2.0.30.
1253 .\"O .B SO_PASSCRED
1254 .\"O is new in Linux 2.2.
1255 .\"O The
1256 .\"O .I /proc
1257 .\"O interfaces was introduced in Linux 2.2.
1258 .B SO_BINDTODEVICE
1259 は Linux 2.0.30 で導入された。
1260 .B SO_PASSCRED
1261 は Linux 2.2 で登場した。
1262 .I /proc
1263 インタフェースは Linux 2.2 で導入された。
1264 .\"O .B SO_RCVTIMEO
1265 .\"O and
1266 .\"O .B SO_SNDTIMEO
1267 .\"O are supported since Linux 2.3.41.
1268 .\"O Earlier, timeouts were fixed to
1269 .\"O a protocol-specific setting, and could not be read or written.
1270 .B SO_RCVTIMEO
1271
1272 .B SO_SNDTIMEO
1273 は Linux 2.3.41 以降でサポートされている。
1274 それ以前は、タイムアウトはプロトコル固有の固定の設定値で、
1275 読み書きをすることはできなかった。
1276 .\"O .SH NOTES
1277 .SH 注意
1278 .\"O Linux assumes that half of the send/receive buffer is used for internal
1279 .\"O kernel structures; thus the values in the corresponding
1280 .\"O .I /proc
1281 .\"O files are twice what can be observed on the wire.
1282 Linux は、送受信バッファの半分を内部のカーネル構造体で用いると仮定している。
1283 したがって、対応する
1284 .I /proc
1285 ファイルはネットワーク回線上での大きさの 2 倍になる。
1286
1287 .\"O Linux will only allow port reuse with the
1288 .\"O .B SO_REUSEADDR
1289 .\"O option
1290 .\"O when this option was set both in the previous program that performed a
1291 .\"O .BR bind (2)
1292 .\"O to the port and in the program that wants to reuse the port.
1293 .\"O This differs from some implementations (e.g., FreeBSD)
1294 .\"O where only the later program needs to set the
1295 .\"O .B SO_REUSEADDR
1296 .\"O option.
1297 .\"O Typically this difference is invisible, since, for example, a server
1298 .\"O program is designed to always set this option.
1299 Linux では、
1300 .B SO_REUSEADDR
1301 オプションでポートの再利用が許可されるのは、
1302 そのポートに対して
1303 .BR bind (2)
1304 を前に実行したプログラムとそのポートを再利用
1305 しようとするプログラムの両方で
1306 .B SO_REUSEADDR
1307 がセットされた場合のみである。
1308 この動作は (FreeBSD などの) いくつかの実装とは異なる。これらでは、
1309 後でポートを再利用しようとするプログラムで
1310 .B SO_REUSEADDR
1311 オプションをセットするだけでよい。
1312 たいていはこの違いは見えない。なぜなら、例えばサーバプログラムは
1313 常にこのオプションをセットするように設計されるからである。
1314 .\"O .SH BUGS
1315 .SH バグ
1316 .\"O The
1317 .\"O .B CONFIG_FILTER
1318 .\"O socket options
1319 .\"O .B SO_ATTACH_FILTER
1320 .\"O and
1321 .\"O .B SO_DETACH_FILTER
1322 .\" FIXME Document SO_ATTACH_FILTER and SO_DETACH_FILTER
1323 .\"O are not documented.
1324 .\"O The suggested interface to use them is via the libpcap
1325 .\"O library.
1326 .B CONFIG_FILTER
1327 ソケットオプションである
1328 .B SO_ATTACH_FILTER
1329
1330 .B SO_DETACH_FILTER
1331 について記載されていない。これらは libpcap ライブラリを通して
1332 用いる方が良い。
1333 .\"O .\" .SH AUTHORS
1334 .\" .SH 著者
1335 .\"O .\" This man page was written by Andi Kleen.
1336 .\" この man ページは Andi Kleen が書いた。
1337 .\"O .SH SEE ALSO
1338 .SH 関連項目
1339 .BR getsockopt (2),
1340 .BR setsockopt (2),
1341 .BR socket (2),
1342 .BR capabilities (7),
1343 .BR ddp (7),
1344 .BR ip (7),
1345 .BR packet (7),
1346 .BR tcp (7),
1347 .BR udp (7),
1348 .BR unix (7)