OSDN Git Service

(split) LDP: Update draft pages
[linuxjm/LDP_man-pages.git] / draft / man7 / socket.7
index 5037200..7e5ca29 100644 (file)
@@ -38,9 +38,6 @@
 .\"            commit 6e3e939f3b1bf8534b32ad09ff199d88800835a0
 .\"            Author: Johannes Berg <johannes.berg@intel.com>
 .\"            Also: SCM_WIFI_STATUS
-.\"    SO_PEEK_OFF (3.4)
-.\"            commit ef64a54f6e558155b4f149bb10666b9e914b6c54
-.\"            Author: Pavel Emelyanov <xemul@parallels.com>
 .\"    SO_NOFCS (3.4)
 .\"            commit 3bdc0eba0b8b47797f4a76e377dd8360f317450f
 .\"            Author: Ben Greear <greearb@candelatech.com>
@@ -50,7 +47,7 @@
 .\" This file was generated with po4a. Translate the source file.
 .\"
 .\"*******************************************************************
-.TH SOCKET 7 2013\-03\-15 Linux "Linux Programmer's Manual"
+.TH SOCKET 7 2013\-06\-21 Linux "Linux Programmer's Manual"
 .SH 名前
 socket \- Linux のソケットインターフェース
 .SH 書式
@@ -177,7 +174,8 @@ T}
 .\" 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 を指定すること。
+但し、どのソケットの場合も ソケットレベルには \fBSOL_SOCKET\fP を指定すること。 注釈がない限り、 \fIoptval\fP は \fIint\fP
+へのポインタである。
 .TP 
 \fBSO_ACCEPTCONN\fP
 このソケットが \fBlisten\fP(2)  によって接続待ち受け状態に設定されているかどうかを示す値を返す。 値 0 は listen
@@ -262,6 +260,54 @@ struct linger {
 .\" in the 2.6.18 ChangeLog
 \fBSCM_CREDENTIALS\fP 制御メッセージの受信を有効/無効にする。詳細は \fBunix\fP(7)  を参照のこと。
 .TP 
+\fBSO_PEEK_OFF\fP (Linux 3.4 以降)
+.\" commit ef64a54f6e558155b4f149bb10666b9e914b6c54
+This option, which is currently supported only for \fBunix\fP(7)  sockets, sets
+the value of the "peek offset" for the \fBrecv(2)\fP system call when used with
+\fBMSG_PEEK\fP flag.
+
+When this option is set to a negative value (it is set to \-1 for all new
+sockets), traditional behavior is provided: \fBrecv(2)\fP with the \fBMSG_PEEK\fP
+flag will peek data from the front of the queue.
+
+When the option is set to a value greater than or equal to zero, then the
+next peek at data queued in the socket will occur at the byte offset
+specified by the option value.  At the same time, the "peek offset" will be
+incremented by the number of bytes that were peeked from the queue, so that
+a subsequent peek will return the next data in the queue.i
+
+If data is removed from the front of the queue via a call to \fBrecv\fP(2)  (or
+similar) without the \fBMSG_PEEK\fP flag, the "peek offset" will be decreased
+by the number of bytes removed.  In other words, receiving data without the
+\fBMSG_PEEK\fP flag will cause the "peek offset" to be adjusted to maintain the
+correct relative position in the queued data, so that a subsequent peek will
+retrieve the data that would have been retrieved had the data not been
+removed.
+
+For datagram sockets, if the "peek offset" points to the middle of a packet,
+the data returned will be marked with the \fBMSG_TRUNC\fP flag.
+
+The following example serves to illustrate the use of \fBSO_PEEK_OFF\fP.
+Suppose a stream socket has the following queued input data:
+
+    aabbccddeeff
+
+.IP
+The following sequence of \fBrecv\fP(2)  calls would have the effect noted in
+the comments:
+
+.in +4n
+.nf
+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
+.fi
+.in
+.TP 
 \fBSO_PEERCRED\fP
 このソケットに接続してきた外部プロセスの信任状 (credential) を返す。このソケットオプションが利用できるのは、接続された
 \fBAF_UNIX\fP ストリームソケット間、および \fBsocketpair\fP(2) を使って作成された \fBAF_UNIX\fP
@@ -448,6 +494,6 @@ Linux では、 \fBSO_REUSEADDR\fP オプションでポートの再利用が許
 \fBcapabilities\fP(7), \fBddp\fP(7), \fBip\fP(7), \fBpacket\fP(7), \fBtcp\fP(7), \fBudp\fP(7),
 \fBunix\fP(7)
 .SH この文書について
-この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.51 の一部
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.52 の一部
 である。プロジェクトの説明とバグ報告に関する情報は
 http://www.kernel.org/doc/man\-pages/ に書かれている。