OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / draft / man2 / getsockopt.2
1 .\" Copyright (c) 1983, 1991 The Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     $Id: getsockopt.2,v 1.1 1999/05/24 14:57:04 freitag Exp $
33 .\"
34 .\" Modified Sat Jul 24 16:19:32 1993 by Rik Faith (faith@cs.unc.edu)
35 .\" Modified Mon Apr 22 02:29:06 1996 by Martin Schulze (joey@infodrom.north.de)
36 .\" Modified Tue Aug 27 10:52:51 1996 by Andries Brouwer (aeb@cwi.nl)
37 .\" Modified Thu Jan 23 13:29:34 1997 by Andries Brouwer (aeb@cwi.nl)
38 .\" Modified Sun Mar 28 21:26:46 1999 by Andries Brouwer (aeb@cwi.nl)
39 .\" Modified 1999 by Andi Kleen <ak@muc.de>.
40 .\"     Removed most stuff because it is in socket.7 now.
41 .\"
42 .\" Japanese Version Copyright (c) 1996 Akira Yoshiyama
43 .\"         all rights reserved.
44 .\" Translated Sat Jul  6 00:43:37 JST 1996
45 .\"         by Akira Yoshiyama <yosshy@jedi.seg.kobe-u.ac.jp>
46 .\" Modified Fri Nov  7 22:45:27 JST 1997
47 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
48 .\" Updated Sun Oct 12 JST 2003 by Kentaro Shirakata <argrath@ub32.org>
49 .\"
50 .TH GETSOCKOPT 2 2008-12-03 "Linux" "Linux Programmer's Manual"
51 .\"O .SH NAME
52 .SH Ì¾Á°
53 .\"O getsockopt, setsockopt \- get and set options on sockets
54 getsockopt, setsockopt \- ¥½¥±¥Ã¥È¤Î¥ª¥×¥·¥ç¥ó¤ÎÀßÄê¤È¼èÆÀ¤ò¹Ô¤Ê¤¦
55 .\"O .SH SYNOPSIS
56 .SH ½ñ¼°
57 .nf
58 .\"O .BR "#include <sys/types.h>" "          /* See NOTES */"
59 .BR "#include <sys/types.h>" "          /* ¡ÖÃí°Õ¡×»²¾È */"
60 .br
61 .B #include <sys/socket.h>
62 .sp
63 .BI "int getsockopt(int " sockfd ", int " level ", int " optname ,
64 .BI "               void *" optval ", socklen_t *" optlen );
65 .BI "int setsockopt(int " sockfd ", int " level ", int " optname ,
66 .BI "               const void *" optval ", socklen_t " optlen );
67 .fi
68 .\"O .SH DESCRIPTION
69 .SH ÀâÌÀ
70 .\"O .BR getsockopt ()
71 .\"O and
72 .\"O .BR setsockopt ()
73 .\"O manipulate options for the socket referred to by the file descriptor
74 .\"O .IR sockfd .
75 .\"O Options may exist at multiple
76 .\"O protocol levels; they are always present at the uppermost
77 .\"O socket level.
78 .BR getsockopt ()
79 ¤È
80 .BR setsockopt ()
81 ¤Ï¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
82 .I socket
83 ¤Ç»²¾È¤µ¤ì¤ë¥½¥±¥Ã¥È¤Ë´ØÏ¢¤¹¤ë¥ª¥×¥·¥ç¥ó¤ÎÁàºî¤ò¹Ô¤¦¡£
84 ¥ª¥×¥·¥ç¥ó¤ÏÊ£¿ô¤Î¥×¥í¥È¥³¥ëÁØ(level)¤Ë¸ºß¤¹¤ë¤«¤â¤·¤ì¤Ê¤¤¤¬¡¢
85 ¤³¤ì¤é¤Ï¾ï¤ËºÇ¾å°Ì¤Î¥½¥±¥Ã¥ÈÁؤؤÈÀßÄꤵ¤ì¤ë¡£
86
87 .\"O When manipulating socket options, the level at which the
88 .\"O option resides and the name of the option must be specified.
89 .\"O To manipulate options at the sockets API level,
90 .\"O .I level
91 .\"O is specified as
92 .\"O .BR SOL_SOCKET .
93 .\"O To manipulate options at any
94 .\"O other level the protocol number of the appropriate protocol
95 .\"O controlling the option is supplied.
96 .\"O For example,
97 .\"O to indicate that an option is to be interpreted by the
98 .\"O .B TCP
99 .\"O protocol,
100 .\"O .I level
101 .\"O should be set to the protocol number of
102 .\"O .BR TCP ;
103 .\"O see
104 .\"O .BR getprotoent (3).
105 ¥½¥±¥Ã¥È¡¦¥ª¥×¥·¥ç¥ó¤òÁàºî¤¹¤ëºÝ¤Ë¤Ï¡¢¥ª¥×¥·¥ç¥ó¤ÎÁØ (level) ¤È
106 ¥ª¥×¥·¥ç¥ó¤Î̾Á°¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
107 ¥½¥±¥Ã¥È API Áؤǥª¥×¥·¥ç¥ó¤òÁàºî¤¹¤ë°Ù¤Ë¤Ï¡¢
108 .I level
109 ¤ò
110 .B SOL_SOCKET
111 ¤Ë»ØÄꤹ¤ë¡£
112 ¾¤ÎÁ´¤Æ¤ÎÁؤǥª¥×¥·¥ç¥ó¤òÁàºî¤¹¤ë°Ù¤Ë¤Ï¡¢Í¿¤¨¤é¤ì¤¿¥ª¥×¥·¥ç¥ó¤Î
113 À©¸æ¼çÂΤȤʤë¥×¥í¥È¥³¥ë¤Î¥×¥í¥È¥³¥ëÈÖ¹æ¤ò»ØÄꤹ¤ë¡£Î㤨¤Ð¡¢
114 ¥ª¥×¥·¥ç¥ó¤¬
115 .B TCP
116 ¥×¥í¥È¥³¥ë¤Ç²ò¼á¤µ¤ì¤ë¤Ù¤­¤³¤È¤ò»Ø¼¨¤¹¤ë¤Ë¤Ï¡¢
117 .I level
118 ¤Ë
119 .B TCP
120 ¤Î¥×¥í¥È¥³¥ëÈÖ¹æ¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
121 .BR getprotoent (3)
122 ¤ò»²¾È¤¹¤ë¤³¤È¡£
123
124 .\"O The arguments
125 .\"O .I optval
126 .\"O and
127 .\"O .I optlen
128 .\"O are used to access option values for
129 .\"O .BR setsockopt ().
130 .I optval
131 ¤È
132 .I optlen
133 °ú¤­¿ô¤Ï
134 .BR setsockopt ()
135 ¤Î¥ª¥×¥·¥ç¥ó¤ÎÃͤ˥¢¥¯¥»¥¹¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£
136 .\"O For
137 .\"O .BR getsockopt ()
138 .\"O they identify a buffer in which the value for the
139 .\"O requested option(s) are to be returned.
140 .BR getsockopt ()
141 ¤Ç¤ÏÍ׵ᤷ¤¿¥ª¥×¥·¥ç¥ó¤ÎÃͤòÊÖ¤¹¤¿¤á¤Î¥Ð¥Ã¥Õ¥¡¡¼¤ò»ØÄꤹ¤ë¡£
142 .\"O For
143 .\"O .BR getsockopt (),
144 .\"O .I optlen
145 .\"O is a value-result argument, initially containing the
146 .\"O size of the buffer pointed to by
147 .\"O .IR optval ,
148 .\"O and modified on return to indicate the actual size of
149 .\"O the value returned.
150 .\"O If no option value is to be supplied or returned,
151 .\"O .I optval
152 .\"O may be NULL.
153 .BR getsockopt ()
154 ¤Ç¤Ï
155 .I optlen
156 ¤ÏÃͤȷë²ÌξÍѤΰú¤­¿ô¤Ç¡¢ºÇ½é¤Ë
157 .I optval
158 ¤Î»Ø¤·¤Æ¤¤¤ë¥Ð¥Ã¥Õ¥¡¡¼¤Î¥µ¥¤¥º¤òÍ¿¤¨¡¢¼ÂºÝ¤ËÊÖ¤µ¤ì¤ëÃͤΥµ¥¤¥º¤Ë
159 ½ñ¤­´¹¤¨¤é¤ì¤ë¡£¤â¤·¥ª¥×¥·¥ç¥óÃͤòÍ¿¤¨¤º¡¢ÊÖ¤µ¤ì¤â¤·¤Ê¤¤¾ì¹ç¤Ë¤Ï
160 .I optval
161 ¤Ï NULL ¤Ç¤âÎɤ¤¡£
162
163 .\"O .I Optname
164 .\"O and any specified options are passed uninterpreted to the appropriate
165 .\"O protocol module for interpretation.
166 .\"O The include file
167 .\"O .I <sys/socket.h>
168 .\"O contains definitions for socket level options, described below.
169 .\"O Options at
170 .\"O other protocol levels vary in format and name; consult the appropriate
171 .\"O entries in section 4 of the manual.
172 .I optname
173 ¤ª¤è¤Ó»ØÄꤵ¤ì¤¿¥ª¥×¥·¥ç¥ó¤Ï²ò¼á¤µ¤ì¤º¤Ë¡¢Å¬Àڤʥץí¥È¥³¥ë¡¦¥â¥¸¥å¡¼¥ë¤Ë
174 ÅϤµ¤ì¤Æ²ò¼á¤µ¤ì¤ë¡£¥¤¥ó¥¯¥ë¡¼¥É¡¦¥Õ¥¡¥¤¥ë
175 .I <sys/socket.h>
176 ¤Ë¤Ï¸å½Ò¤Î¥½¥±¥Ã¥ÈÁؤΥª¥×¥·¥ç¥ó¤ÎÄêµÁ¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¡£
177 ¾¤Î¥×¥í¥È¥³¥ëÁؤǤÏ̾Á°¤ä·Á¼°¤Ï°Û¤Ê¤ë¡£
178 ¥Þ¥Ë¥å¥¢¥ë¤Î¥»¥¯¥·¥ç¥ó 4 ¤ÎŬÀڤʥ¨¥ó¥È¥ê¤ò»²¾È¤¹¤ë¤³¤È¡£
179
180 .\"O Most socket-level options utilize an
181 .\"O .I int
182 .\"O argument for
183 .\"O .IR optval .
184 .\"O For
185 .\"O .BR setsockopt (),
186 .\"O the argument should be nonzero to enable a boolean option, or zero if the
187 .\"O option is to be disabled.
188 ¤Û¤È¤ó¤É¤Î¥½¥±¥Ã¥ÈÁؤΥª¥×¥·¥ç¥ó¤Ï
189 .I optval
190 ¤Ë
191 .I int
192 °ú¤­¿ô¤òÍøÍѤ¹¤ë¡£
193 .BR setsockopt ()
194 ¤Ç¡¢ÆóÃÍ(boolean)¥ª¥×¥·¥ç¥ó¤òÍ­¸ú(enable)¤Ë¤¹¤ë¤Ë¤Ï¥¼¥í°Ê³°¤ò»ØÄꤷ¡¢
195 ̵¸ú(disable)¤Ë¤¹¤ë¤Ë¤Ï¥¼¥í¤ò»ØÄꤹ¤ë¡£
196 .PP
197 .\"O For a description of the available socket options see
198 .\"O .BR socket (7)
199 .\"O and the appropriate protocol man pages.
200 ÍøÍѲÄǽ¤Ê¥½¥±¥Ã¥È¥ª¥×¥·¥ç¥ó¤ÎÀâÌÀ¤Ë´Ø¤·¤Æ¤Ï¡¢
201 .BR socket (7)
202 ¤ÈŬÀڤʥץí¥È¥³¥ë¤Î man ¥Ú¡¼¥¸¤ò»²¾È¤Î¤³¤È¡£
203 .\"O .SH "RETURN VALUE"
204 .SH ÊÖ¤êÃÍ
205 .\"O On success, zero is returned.
206 .\"O On error, \-1 is returned, and
207 .\"O .I errno
208 .\"O is set appropriately.
209 À®¸ù¤·¤¿¾ì¹ç¤Ë¤Ï¥¼¥í¤òÊÖ¤¹¡£¥¨¥é¡¼»þ¤Ë¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢
210 .I errno
211 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
212 .\"O .SH ERRORS
213 .SH ¥¨¥é¡¼
214 .TP 10
215 .B EBADF
216 .\"O The argument
217 .\"O .I sockfd
218 .\"O is not a valid descriptor.
219 °ú¤­¿ô
220 .I sockfd
221 ¤¬Í­¸ú¤Ê¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤¤¡£
222 .TP
223 .B EFAULT
224 .\"O The address pointed to by
225 .\"O .I optval
226 .\"O is not in a valid part of the process address space.
227 .\"O For
228 .\"O .BR getsockopt (),
229 .\"O this error may also be returned if
230 .\"O .I optlen
231 .\"O is not in a valid part of the process address space.
232 .I optval
233 ¤Ç»ØÄꤵ¤ì¤¿¥¢¥É¥ì¥¹¤¬¥×¥í¥»¥¹¤Î¥¢¥É¥ì¥¹¶õ´Ö¤ÎÍ­¸ú¤ÊÉôʬ¤Ç¤Ï¤Ê¤¤¡£
234 .BR getsockopt ()
235 ¤Î¾ì¹ç¡¢
236 .I optlen
237 ¤¬¥×¥í¥»¥¹¤Î¥¢¥É¥ì¥¹¶õ´Ö¤ÎÍ­¸ú¤ÊÉôʬ¤Ç¤Ê¤¤¾ì¹ç¤Ë¤â¤³¤Î¥¨¥é¡¼¤¬ÊÖ¤µ¤ì¤ë¡£
238 .TP
239 .B EINVAL
240 .\"O .I optlen
241 .\"O invalid in
242 .\"O .BR setsockopt ().
243 .BR setsockopt ()
244 ¤Ç
245 .I option
246 ¤¬ÉÔÀµ¤Ç¤¢¤ë¡£
247 .\"O In some cases this error can also occur for an invalid value in
248 .\"O .IR optval
249 .\"O (e.g., for the
250 .\"O .B IP_ADD_MEMBERSHIP
251 .\"O option described in
252 .\"O .BR ip (7)).
253 .I optval
254 ¤Ë̵¸ú¤ÊÃͤ¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤â¡¢¤³¤Î¥¨¥é¡¼¤¬È¯À¸¤¹¤ë²ÄǽÀ­¤¬¤¢¤ë
255 (Î㤨¤Ð¡¢
256 .BR ip (7)
257 ¤ËÀâÌÀ¤¬¤¢¤ë
258 .B IP_ADD_MEMBERSHIP
259 ¥ª¥×¥·¥ç¥ó¤Ê¤É)¡£
260 .TP
261 .B ENOPROTOOPT
262 .\"O The option is unknown at the level indicated.
263 »ØÄꤵ¤ì¤¿ÁØ(level)¤Ë¤Ï¤³¤Î¥ª¥×¥·¥ç¥ó¤Ï¸ºß¤·¤Ê¤¤¡£
264 .TP
265 .B ENOTSOCK
266 .\"O The argument
267 .\"O .I sockfd
268 .\"O is a file, not a socket.
269 °ú¤­¿ô
270 .I sockfd
271 ¤Ï¥Õ¥¡¥¤¥ë¤Ç¤¢¤ê¡¢¥½¥±¥Ã¥È¤Ç¤Ê¤¤¡£
272 .\"O .SH "CONFORMING TO"
273 .SH ½àµò
274 .\"O SVr4, 4.4BSD (these system calls first appeared in 4.2BSD),
275 .\"O POSIX.1-2001.
276 .\"O .\" SVr4 documents additional ENOMEM and ENOSR error codes, but does
277 .\"O .\" not document the
278 .\"O .\" .BR SO_SNDLOWAT ", " SO_RCVLOWAT ", " SO_SNDTIMEO ", " SO_RCVTIMEO
279 .\"O .\" options
280 SVr4, 4.4BSD (¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë¤Ï 4.2BSD ¤ÇºÇ½é¤Ë¸½¤ì¤¿),
281 POSIX.1-2001.
282 .\" SVr4 ¤Ë¤Ï¾¤Ë ENOMEM ¤È ENOSR ¥¨¥é¡¼¡¦¥³¡¼¥É¤Ë¤Ä¤¤¤Æ¤âµ­½Ò¤µ¤ì¤Æ¤¤¤ë¡£
283 .\" ¤·¤«¤·¡¢
284 .\" .BR SO_SNDLOWAT ", " SO_RCVLOWAT ", " SO_SNDTIMEO ", " SO_RCVTIMEO
285 .\" ¥ª¥×¥·¥ç¥ó¤Ë´Ø¤¹¤ëµ­½Ò¤Ï¤Ê¤¤¡£
286 .\"O .SH NOTES
287 .SH Ãí°Õ
288 .\"O POSIX.1-2001 does not require the inclusion of
289 .\"O .IR <sys/types.h> ,
290 .\"O and this header file is not required on Linux.
291 .\"O However, some historical (BSD) implementations required this header
292 .\"O file, and portable applications are probably wise to include it.
293 POSIX.1-2001 ¤Ç¤Ï
294 .I <sys/types.h>
295 ¤Î¥¤¥ó¥¯¥ë¡¼¥É¤Ïɬ¿Ü¤È¤µ¤ì¤Æ¤ª¤é¤º¡¢
296 Linux ¤Ç¤Ï¤³¤Î¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤ÏɬÍפǤϤʤ¤¡£
297 ¤·¤«¤·¡¢Îò»ËŪ¤Ë¤Ï¡¢¤¤¤¯¤Ä¤«¤Î¼ÂÁõ (BSD ·Ï) ¤Ç¤³¤Î¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤¬
298 ɬÍפǤ¢¤ê¡¢°Ü¿¢À­¤¬É¬Íפʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¤³¤Î¥Õ¥¡¥¤¥ë¤ò
299 ¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¤Î¤¬¸­ÌÀ¤Ç¤¢¤í¤¦¡£
300
301 .\"O The
302 .\"O .I optlen
303 .\"O argument of
304 .\"O .BR getsockopt ()
305 .\"O and
306 .\"O .BR setsockopt ()
307 .\"O is in reality an
308 .\"O .I "int [*]"
309 .\"O (and this is what 4.x BSD and libc4 and libc5 have).
310 .BR getsockopt ()
311 ¤È
312 .BR setsockopt ()
313 ¤Î
314 .I optlen
315 °ú¤­¿ô¤Ï¼ÂºÝ¤Ï
316 .I int [*]
317 ¤Ç¤¢¤ë (¤½¤·¤Æ 4.x BSD ¤È libc4 ¤È libc5 ¤Ï¤½¤¦¤Ê¤Ã¤Æ¤¤¤ë)¡£
318 .\"O Some POSIX confusion resulted in the present
319 .\"O .IR socklen_t ,
320 .\"O also used by glibc.
321 .\"O See also
322 POSIX ¤Ç¤Ïäþ;¶ÊÀÞ¤ò·Ð¤Æ¸½ºß¤Î
323 .I socklen_t
324 ¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢
325 glibc ¤Ç¤â
326 .I socklen_t
327 ¤ò»È¤Ã¤Æ¤¤¤ë¡£
328 .BR accept (2)
329 ¤â»²¾È¤Î¤³¤È¡£
330 .\"O .SH BUGS
331 .SH ¥Ð¥°
332 .\"O Several of the socket options should be handled at lower levels of the
333 .\"O system.
334 ¥½¥±¥Ã¥È¤Î¥ª¥×¥·¥ç¥ó¤Î¤¤¤¯¤Ä¤«¤Ï¥·¥¹¥Æ¥à¤Î¤è¤êÄ㤤ÁؤÇ
335 ½èÍý¤µ¤ì¤ë¤Ù¤­¤Ç¤¢¤ë¡£
336 .\"O .SH "SEE ALSO"
337 .SH ´ØÏ¢¹àÌÜ
338 .BR ioctl (2),
339 .BR socket (2),
340 .BR getprotoent (3),
341 .BR protocols (5),
342 .BR socket (7),
343 .BR tcp (7),
344 .BR unix (7)