OSDN Git Service

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