OSDN Git Service

5c9b62eeb85ab8058eb76d826d20cbeebe4a2bde
[linuxjm/LDP_man-pages.git] / release / man3 / sockatmark.3
1 .\" Copyright (c) 2006, Michael Kerrisk (mtk.manpages@gmail.com)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\"*******************************************************************
26 .\"
27 .\" This file was generated with po4a. Translate the source file.
28 .\"
29 .\"*******************************************************************
30 .TH SOCKATMARK 3 2008\-12\-03 Linux "Linux Programmer's Manual"
31 .SH 名前
32 sockatmark \- どのソケットに帯域外 (out\-of\-band) マークが付けられているかを調べる
33 .SH 書式
34 \fB#include <sys/socket.h>\fP
35 .sp
36 \fBint sockatmark(int \fP\fIsockfd\fP\fB);\fP
37 .sp
38 .in -4n
39 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
40 .in
41 .sp
42 .ad l
43 \fBsockatmark\fP(): _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
44 .ad b
45 .SH 説明
46 \fBsockatmark\fP()  はファイルディスクリプタ \fIsockfd\fP で参照されるソケットに帯域外マークが付けられているか否かを返す。
47 ソケットにマークが付けられている場合は、1 が返される。 ソケットにマークが付けられていない場合は、0 が返される。
48 この関数は帯域外マークを削除しない。
49 .SH 返り値
50 \fBsockatmark\fP()  の呼び出しが成功した場合、ソケットに帯域外マークが 付けられていれば 1 を返し、付けられていなければ 0 を返す。
51 エラーの場合は \-1 が返され、エラーを表す \fIerrno\fP が設定される。
52 .SH エラー
53 .TP 
54 \fBEBADF\fP
55 \fIsockfd\fP が有効なファイルディスクリプタでない。
56 .TP 
57 \fBEINVAL\fP
58 .\" POSIX.1 says ENOTTY for this case
59 \fIsockfd\fP は \fBsockatmark\fP()  が適用できないファイルディスクリプタである。
60 .SH バージョン
61 \fBsockatmark\fP()  は glibc バージョン 2.2.4 で追加された。
62 .SH 準拠
63 POSIX.1\-2001.
64 .SH 注意
65 \fBsockatmark\fP()  が 1 を返す場合、帯域外データは \fBMSG_OOB\fP を指定した \fBrecv\fP(2)  で読み込むことができる。
66
67 帯域外データは、いくつかのストリームソケットプロトコルでしか サポートされていない。
68
69 \fBsockatmark\fP()  は \fBSIGURG\fP シグナルのハンドラから安全に呼び出すことができる。
70
71 \fBsockatmark\fP()  は \fBSIOCATMARK\fP \fBioctl\fP(2)  操作を使って実装されている。
72 .SH バグ
73 glibc 2.4 より前のバージョンでは、 \fBsockatmark\fP()  は動作しない。
74 .SH 例
75 以下のコードは、 \fBSIGURG\fP シグナルを受け取った後にマークまでの全てのデータを読み込んで (破棄し)、
76 マークされたデータのバイトを読み込むのに使用できる。
77 .nf
78
79     char buf[BUF_LEN];
80     char oobdata;
81     int atmark, s;
82
83     for (;;) {
84         atmark = sockatmark(sockfd);
85         if (atmark == \-1) {
86             perror("sockatmark");
87             break;
88         }
89
90         if (atmark)
91             break;
92
93         s = read(sockfd, buf, BUF_LEN) <= 0);
94         if (s == \-1)
95             perror("read");
96         if (s <= 0)
97             break;
98     }
99
100     if (atmark == 1) {
101         if (recv(sockfd, &oobdata, 1, MSG_OOB) == \-1) {
102             perror("recv");
103             ...
104         }
105     }
106 .fi
107 .SH 関連項目
108 \fBfcntl\fP(2), \fBrecv\fP(2), \fBsend\fP(2), \fBtcp\fP(7)
109 .SH この文書について
110 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.52 の一部
111 である。プロジェクトの説明とバグ報告に関する情報は
112 http://www.kernel.org/doc/man\-pages/ に書かれている。