OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / 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 .\"O .SH NAME
29 .SH Ì¾Á°
30 .\"O sockatmark \- determine whether socket is at out-of-band mark
31 sockatmark \- ¤É¤Î¥½¥±¥Ã¥È¤ËÂÓ°è³° (out-of-band) ¥Þ¡¼¥¯¤¬ÉÕ¤±¤é¤ì¤Æ¤¤¤ë¤«¤òÄ´¤Ù¤ë
32 .\"O .SH SYNOPSIS
33 .SH ½ñ¼°
34 .B #include <sys/socket.h>
35 .sp
36 .BI "int sockatmark(int " sockfd );
37 .sp
38 .in -4n
39 .\"O Feature Test Macro Requirements for glibc (see
40 .\"O .BR feature_test_macros (7)):
41 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
42 .RB ( feature_test_macros (7)
43 »²¾È):
44 .in
45 .sp
46 .ad l
47 .BR sockatmark ():
48 _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
49 .ad b
50 .\"O .SH DESCRIPTION
51 .SH ÀâÌÀ
52 .\"O .BR sockatmark ()
53 .\"O returns a value indicating whether or not the socket referred
54 .\"O to by the file descriptor
55 .\"O .I sockfd
56 .\"O is at the out-of-band mark.
57 .BR sockatmark ()
58 ¤Ï¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
59 .I sockfd
60 ¤Ç»²¾È¤µ¤ì¤ë¥½¥±¥Ã¥È¤ËÂÓ°è³°¥Þ¡¼¥¯¤¬ÉÕ¤±¤é¤ì¤Æ¤¤¤ë¤«Èݤ«¤òÊÖ¤¹¡£
61 .\"O If the socket is at the mark, then 1 is returned;
62 .\"O if the socket is not at the mark, 0 is returned.
63 .\"O This function does not remove the out-of-band mark.
64 ¥½¥±¥Ã¥È¤Ë¥Þ¡¼¥¯¤¬ÉÕ¤±¤é¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢1 ¤¬ÊÖ¤µ¤ì¤ë¡£
65 ¥½¥±¥Ã¥È¤Ë¥Þ¡¼¥¯¤¬ÉÕ¤±¤é¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢0 ¤¬ÊÖ¤µ¤ì¤ë¡£
66 ¤³¤Î´Ø¿ô¤ÏÂÓ°è³°¥Þ¡¼¥¯¤òºï½ü¤·¤Ê¤¤¡£
67 .\"O .SH "RETURN VALUE"
68 .SH ÊÖ¤êÃÍ
69 .\"O A successful call to
70 .\"O .BR sockatmark ()
71 .\"O returns 1 if the socket is at the out-of-band mark, or 0 if it is not.
72 .\"O On error, \-1 is returned and \fIerrno\fP is set to indicate the error.
73 .BR sockatmark ()
74 ¤Î¸Æ¤Ó½Ð¤·¤¬À®¸ù¤·¤¿¾ì¹ç¡¢¥½¥±¥Ã¥È¤ËÂÓ°è³°¥Þ¡¼¥¯¤¬
75 ÉÕ¤±¤é¤ì¤Æ¤¤¤ì¤Ð 1 ¤òÊÖ¤·¡¢ÉÕ¤±¤é¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð 0 ¤òÊÖ¤¹¡£
76 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢¥¨¥é¡¼¤òɽ¤¹ \fIerrno\fP ¤¬ÀßÄꤵ¤ì¤ë¡£
77 .\"O .SH ERRORS
78 .SH ¥¨¥é¡¼
79 .TP
80 .B EBADF
81 .\"O .I sockfd
82 .\"O is not a valid file descriptor.
83 .I sockfd
84 ¤¬Í­¸ú¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤¤¡£
85 .TP
86 .B EINVAL
87 .\" POSIX.1 says ENOTTY for this case
88 .\"O .I sockfd
89 .\"O is not a file descriptor to which
90 .\"O .BR sockatmark ()
91 .\"O can be applied.
92 .I sockfd
93 ¤Ï
94 .BR sockatmark ()
95 ¤¬Å¬ÍѤǤ­¤Ê¤¤¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤¢¤ë¡£
96 .\"O .SH VERSIONS
97 .SH ¥Ð¡¼¥¸¥ç¥ó
98 .\"O .BR sockatmark ()
99 .\"O was added to glibc in version 2.2.4.
100 .BR sockatmark ()
101 ¤Ï glibc ¥Ð¡¼¥¸¥ç¥ó 2.2.4 ¤ÇÄɲ䵤줿¡£
102 .\"O .SH "CONFORMING TO"
103 .SH ½àµò
104 POSIX.1-2001.
105 .\"O .SH NOTES
106 .SH Ãí°Õ
107 .\"O If
108 .\"O .BR sockatmark ()
109 .\"O returns 1, then the out-of-band data can be read using the
110 .\"O .B MSG_OOB
111 .\"O flag of
112 .\"O .BR recv (2).
113 .BR sockatmark ()
114 ¤¬ 1 ¤òÊÖ¤¹¾ì¹ç¡¢ÂÓ°è³°¥Ç¡¼¥¿¤Ï
115 .B MSG_OOB
116 ¤ò»ØÄꤷ¤¿
117 .BR recv (2)
118 ¤ÇÆɤ߹þ¤à¤³¤È¤¬¤Ç¤­¤ë¡£
119
120 .\"O Out-of-band data is only supported on some stream socket protocols.
121 ÂÓ°è³°¥Ç¡¼¥¿¤Ï¡¢¤¤¤¯¤Ä¤«¤Î¥¹¥È¥ê¡¼¥à¥½¥±¥Ã¥È¥×¥í¥È¥³¥ë¤Ç¤·¤«
122 ¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
123
124 .\"O .BR sockatmark ()
125 .\"O can safely be called from a handler for the
126 .\"O .B SIGURG
127 .\"O signal.
128 .BR sockatmark ()
129 ¤Ï
130 .B SIGURG
131 ¥·¥°¥Ê¥ë¤Î¥Ï¥ó¥É¥é¤«¤é°ÂÁ´¤Ë¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤­¤ë¡£
132
133 .\"O .BR sockatmark ()
134 .\"O is implemented using the
135 .\"O .B SIOCATMARK
136 .\"O .BR ioctl (2)
137 .\"O operation.
138 .BR sockatmark ()
139 ¤Ï
140 .B SIOCATMARK
141 .BR ioctl (2)
142 Áàºî¤ò»È¤Ã¤Æ¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¡£
143 .\"O .SH BUGS
144 .SH ¥Ð¥°
145 .\"O Prior to glibc 2.4,
146 .\"O .BR sockatmark ()
147 .\"O did not work.
148 glibc 2.4 ¤è¤êÁ°¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï¡¢
149 .BR sockatmark ()
150 ¤ÏÆ°ºî¤·¤Ê¤¤¡£
151 .\"O .SH EXAMPLE
152 .SH Îã
153 .\"O The following code can be used after receipt of a
154 .\"O .B SIGURG
155 .\"O signal to read (and discard) all data up to the mark,
156 .\"O and then read the byte of data at the mark:
157 °Ê²¼¤Î¥³¡¼¥É¤Ï¡¢
158 .B SIGURG
159 ¥·¥°¥Ê¥ë¤ò¼õ¤±¼è¤Ã¤¿¸å¤Ë¥Þ¡¼¥¯¤Þ¤Ç¤ÎÁ´¤Æ¤Î¥Ç¡¼¥¿¤òÆɤ߹þ¤ó¤Ç (ÇË´þ¤·)¡¢
160 ¥Þ¡¼¥¯¤µ¤ì¤¿¥Ç¡¼¥¿¤Î¥Ð¥¤¥È¤òÆɤ߹þ¤à¤Î¤Ë»ÈÍѤǤ­¤ë¡£
161 .nf
162
163     char buf[BUF_LEN];
164     char oobdata;
165     int atmark, s;
166
167     for (;;) {
168         atmark = sockatmark(sockfd);
169         if (atmark == \-1) {
170             perror("sockatmark");
171             break;
172         }
173
174         if (atmark)
175             break;
176
177         s = read(sockfd, buf, BUF_LEN) <= 0);
178         if (s == \-1)
179             perror("read");
180         if (s <= 0)
181             break;
182     }
183
184     if (atmark == 1) {
185         if (recv(sockfd, &oobdata, 1, MSG_OOB) == \-1) {
186             perror("recv");
187             ...
188         }
189     }
190 .fi
191 .\"O .SH "SEE ALSO"
192 .SH ´ØÏ¢¹àÌÜ
193 .BR fcntl (2),
194 .BR recv (2),
195 .BR send (2),
196 .BR tcp (7)