1 .\" Copyright (c) 1983, 1990, 1991 The Regents of the University of California.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
32 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
33 .\" Modified 1996-10-21 by Eric S. Raymond <esr@thyrsus.com>
34 .\" Modified 1998-2000 by Andi Kleen to match Linux 2.2 reality
35 .\" Modified 2002-04-23 by Roger Luethi <rl@hellgate.ch>
36 .\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com>
37 .\" 2008-12-04, mtk, Add documentation of accept4()
39 .\" Japanese Version Copyright (c) 1998-2000 Shinya HANATAKA,
40 .\" Takeshi Hakamada and NAKANO Takeo
41 .\" all rights reserved.
42 .\" Translated 1998-04-06, Shinya HANATAKA <shinya@abyss.rim.or.jp>
43 .\" Takeshi Hakamada <hakamada@nsg.sgi.com>
44 .\" Updated & Modified 2000-10-12, NAKANO Takeo <nakano@apm.seikei.ac.jp
45 .\" Updated & Modified 2002-09-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
46 .\" Updated & Modified 2005-02-23, Akihiro MOTOKI
47 .\" Updated & Modified 2006-04-14, Akihiro MOTOKI, LDP v2.29
48 .\" Updated & Modified 2008-12-24, Akihiro MOTOKI, LDP v3.15
49 .\" Updated 2008-04-13, Akihiro MOTOKI, LDP v3.20
51 .\"WORD: pending ÊÝαÃæ¤Î
53 .\"WORD: file descriptor ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿
54 .\"WORD: nonblocking ÈóÄä»ß
56 .\"WORD: communication layer ÄÌ¿®ÁØ
57 .\"WORD: value-result argument Æþ½ÐÎÏξÍѤΰú¤¿ô
58 .\"WORD: confirmation Àܳ³Îǧ
59 .\"WORD: dequeue ¥¥å¡¼¤«¤é¼è¤ê½Ð¤¹
60 .\"WORD: rejection ÀܳµñÈÝ
62 .TH ACCEPT 2 2009-02-23 "Linux" "Linux Programmer's Manual"
64 .\"O accept \- accept a connection on a socket
66 accept \- ¥½¥±¥Ã¥È¤Ø¤ÎÀܳ¤ò¼õ¤±¤ë
70 .\"O .BR "#include <sys/types.h>" " /* See NOTES */"
71 .BR "#include <sys/types.h>" " /* ¡ÖÃí°Õ¡×»²¾È */"
72 .B #include <sys/socket.h>
74 .BI "int accept(int " sockfd ", struct sockaddr *" addr ", socklen_t *" addrlen );
76 .B #define _GNU_SOURCE
77 .B #include <sys/socket.h>
79 .BI "int accept4(int " sockfd ", struct sockaddr *" addr ,
80 .BI " socklen_t *" addrlen ", int " flags );
86 .\"O system call is used with connection-based socket types
87 .\"O .RB ( SOCK_STREAM ,
88 .\"O .BR SOCK_SEQPACKET ).
90 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢Àܳ»Ø¸þ¤Î¥½¥±¥Ã¥È·¿
91 .RB ( SOCK_STREAM ", " SOCK_SEQPACKET )
93 .\"O It extracts the first connection request on the queue of pending
94 .\"O connections for the listening socket,
96 .\"O creates a new connected socket, and returns a new file
97 .\"O descriptor referring to that socket.
98 ¤³¤Î´Ø¿ô¤Ï¡¢ÀܳÂÔ¤Á¥½¥±¥Ã¥È
100 °¸¤Æ¤ÎÊÝα¾õÂÖ¤ÎÀܳÍ׵᤬Æþ¤Ã¤Æ¤¤¤ë¥¥å¡¼¤«¤é
101 ÀèƬ¤ÎÀܳÍ×µá¤ò¼è¤ê½Ð¤·¡¢ÀܳºÑ¤ß¥½¥±¥Ã¥È¤ò¿·µ¬¤ËÀ¸À®¤·¡¢
102 ¤½¤Î¥½¥±¥Ã¥È¤ò»²¾È¤¹¤ë¿·¤·¤¤¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¡£
103 .\"O The newly created socket is not in the listening state.
104 ¿·µ¬¤ËÀ¸À®¤µ¤ì¤¿¥½¥±¥Ã¥È¤Ï¡¢ÀܳÂÔ¤Á (listen) ¾õÂ֤ǤϤʤ¤¡£
105 .\"O The original socket
107 .\"O is unaffected by this call.
110 ¤Ï¤³¤Î¸Æ¤Ó½Ð¤·¤Ë¤è¤Ã¤Æ±Æ¶Á¤ò¼õ¤±¤Ê¤¤¡£
114 .\"O is a socket that has been created with
116 .\"O bound to a local address with
118 .\"O and is listening for connections after a
126 ¤Ë¤è¤Ã¤Æ¥í¡¼¥«¥ë¥¢¥É¥ì¥¹¤Ë¥Ð¥¤¥ó¥É¤µ¤ì¡¢
128 ¤ò·Ð¤ÆÀܳ¤òÂԤäƤ¤¤ë¥½¥±¥Ã¥È¤Ç¤¢¤ë¡£
132 .\"O is a pointer to a
135 .\"O This structure is filled in with the address of the peer socket,
136 .\"O as known to the communications layer.
137 .\"O The exact format of the address returned
139 .\"O is determined by the socket's address family (see
141 .\"O and the respective protocol man pages).
145 ¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤Ç¤¢¤ë¡£
146 ¤³¤Î¹½Â¤ÂΤˤÏÀܳÁê¼ê¤Î¥½¥±¥Ã¥È¤Î¥¢¥É¥ì¥¹¤¬Æþ¤Ã¤Æ¤¤¤ë¡£
148 °ú¤¿ô¤ÇÊÖ¤µ¤ì¤ë¥¢¥É¥ì¥¹¤ÎÀµ³Î¤Ê¥Õ¥©¡¼¥Þ¥Ã¥È¤Ï¡¢
149 ¥½¥±¥Ã¥È¤Î¥¢¥É¥ì¥¹¼ïÊ̤ˤè¤Ã¤ÆÊѤï¤ë
151 ¤ª¤è¤Ó¤½¤ì¤¾¤ì¤Î¥×¥í¥È¥³¥ë¤Î man ¥Ú¡¼¥¸¤ò»²¾È)¡£
154 .\"O is NULL, nothing is filled in; in this case,
156 .\"O is not used, and should also be NULL.
160 ¤Ë¤Ï²¿¤âÆþ¤é¤Ê¤¤¡£¤³¤Î¾ì¹ç¡¢
162 ¤Ï»ÈÍѤµ¤ì¤º¡¢¤³¤Î°ú¤¿ô¤Ï NULL ¤Ë¤·¤Æ¤ª¤¯¤Ù¤¤Ç¤¢¤ë¡£
166 .\"O argument is a value-result argument:
167 .\"O the caller must initialize it to contain the
168 .\"O size (in bytes) of the structure pointed to by
170 .\"O on return it will contain the actual size of the peer address.
172 °ú¤¿ô¤ÏÆþ½ÐÎÏξÍѤΰú¤¿ô¤Ç¤¢¤ë¡£¸Æ¤Ó½Ð¤·»þ¤Ë¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¤¬
174 ¤¬»Ø¤¹¹½Â¤ÂΤΥµ¥¤¥º (¥Ð¥¤¥Èñ°Ì) ¤Ç½é´ü²½¤·¤Æ¤ª¤«¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
175 Ê֤äƤ¯¤ë»þ¤Ë¤Ï¡¢ÀܳÁê¼ê¤Î¥¢¥É¥ì¥¹¤Î¼ÂºÝ¤ÎÂ礤µ¤¬³ÊǼ¤µ¤ì¤ë¡£
177 .\"O The returned address is truncated if the buffer provided is too small;
180 .\"O will return a value greater than was supplied to the call.
181 ÅϤµ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤¬¾®¤µ²á¤®¤ë¾ì¹ç¤Ë¤Ï¡¢ÊÖ¤µ¤ì¤ë¥¢¥É¥ì¥¹¤ÎËöÈø¤Ï
182 ÀÚ¤êµÍ¤á¤é¤ì¤ë¡£¤³¤Î¾ì¹ç¤Ë¤Ï¡¢
184 ¤Ç¤Ï¡¢¸Æ¤Ó½Ð¤·»þ¤ËÅϤµ¤ì¤¿Ãͤè¤ê¤âÂ礤ÊÃͤ¬ÊÖ¤µ¤ì¤ë¡£
187 .\"O connections are present on the queue, and the socket is not marked as
190 .\"O blocks the caller until a connection is present.
191 .\"O If the socket is marked
192 .\"O nonblocking and no pending connections are present on the queue,
194 .\"O fails with the error
197 .\"O .BR EWOULDBLOCK .
198 ¥¥å¡¼¤ËÊÝα¤È¤Ê¤Ã¤Æ¤¤¤ëÀܳÍ׵᤬¤Ê¤¯¡¢
199 ¤«¤Ä¥½¥±¥Ã¥È¤¬ÈóÄä»ß¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤¤¤È¤¤Ï¡¢
201 ¤ÏÀܳ¤¬È¯À¸¤¹¤ë¤Þ¤Ç¸Æ¤Ó½Ð¤·¸µ¤òÄä»ß (block) ¤¹¤ë¡£
202 ¥½¥±¥Ã¥È¤¬ÈóÄä»ß¤Ë¤Ê¤Ã¤Æ¤¤¤Æ¡¢
203 ÂÔ¤Á¾õÂÖ¤ÎÀܳÍ׵᤬¥¥å¡¼¤Ë̵¤¤¤È¤¤Ï¡¢
211 .\"O In order to be notified of incoming connections on a socket, you can use
215 .\"O A readable event will be delivered when a new connection is attempted and you
218 .\"O to get a socket for that connection.
219 .\"O Alternatively, you can set the socket to deliver
221 .\"O when activity occurs on a socket; see
224 ¥½¥±¥Ã¥È¤Ø¤ÎÀܳÅþÃå¤òÃΤë¤Ë¤Ï¡¢
229 ¿·¤·¤¤ÀܳÍ׵᤬Íè¤ë¤È¥½¥±¥Ã¥È¤ÏÆɤ߹þ¤ß²Äǽ¤Ë¤Ê¤ë¤Î¤Ç¡¢
232 ¤ò¸Æ¤ó¤Ç¤½¤ÎÀܳ¤ËÂФ¹¤ë¥½¥±¥Ã¥È¤ò¼èÆÀ¤¹¤ì¤Ð¤è¤¤¡£
233 ¤¢¤ë¤¤¤Ï¥½¥±¥Ã¥È¤ËÀßÄê¤ò¹Ô¤¤¡¢²¿¤é¤«¤Î¥¢¥¯¥·¥ç¥ó¤¬¤¢¤Ã¤¿¤È¤¤Ë
235 ¤òÇÛÁ÷ (deliver) ¤µ¤»¤ë¤è¤¦¤Ë¤¹¤ë¤³¤È¤â¤Ç¤¤ë¡£¾ÜºÙ¤Ï
239 .\"O For certain protocols which require an explicit confirmation,
243 .\"O can be thought of as merely dequeuing the next connection request and not
244 .\"O implying confirmation.
245 .\"O Confirmation can be implied by
246 .\"O a normal read or write on the new file descriptor, and rejection can be
247 .\"O implied by closing the new socket.
250 .\"O has these semantics on Linux.
251 ÌÀ¼¨Åª¤ÊÀܳ³Îǧ (confirmation) ¤òɬÍפȤ¹¤ë¤è¤¦¤Ê¥×¥í¥È¥³¥ë
254 ¤Ïñ¤Ë¼¡¤ÎÀܳÍ×µá¤ò¥¥å¡¼¤«¤é¼è¤ê½Ð¤¹¤À¤±¤Ç¤¢¤ê¡¢
255 Àܳ³Îǧ¤Ï¹Ô¤ï¤Ê¤¤¤³¤È¤ËÃí°Õ¤»¤è¡£Àܳ³Îǧ¤Ï¡¢
256 ¿·¤·¤¤¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ¹¤ë
257 Ä̾ï¤ÎÆɤ߼è¤ê/½ñ¤¹þ¤ß¤Ë¤è¤Ã¤Æ¤Ê¤µ¤ì¡¢ÀܳµñÈÝ (rejection)
258 ¤Ï¿·¤·¤¤¥½¥±¥Ã¥È¤ò¥¯¥í¡¼¥º¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¤Ê¤µ¤ì¤ë¡£
260 Linux ¾å¤Ç¤³¤ì¤é¤Î¥»¥Þ¥ó¥Æ¥£¥¯¥¹¤ò»ý¤Ä¤Î¤Ï DECNet ¤À¤±¤Ç¤¢¤ë¡£
268 .\"O The following values can be bitwise ORed in
270 .\"O to obtain different behavior:
278 ¤Ë°Ê²¼¤ÎÃͤò¥Ó¥Ã¥ÈËè¤ÎÏÀÍýÏ (OR) ¤Ç»ØÄꤹ¤ë¤³¤È¤Ç¡¢
279 °Û¤Ê¤ëÆ°ºî¤ò¤µ¤»¤ë¤³¤È¤¬¤Ç¤¤ë¡£
284 .\"O file status flag on the new open file description.
285 .\"O Using this flag saves extra calls to
287 .\"O to achieve the same result.
288 ¿·¤·¤¯À¸À®¤µ¤ì¤ë¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ëµ½Ò (open file description) ¤Î
290 ¥Õ¥¡¥¤¥ë¥¹¥Æ¡¼¥¿¥¹¥Õ¥é¥°¤ò¥»¥Ã¥È¤¹¤ë¡£
291 ¤³¤Î¥Õ¥é¥°¤ò»È¤¦¤³¤È¤Ç¡¢
295 ¤òÄɲäǸƤӽФ¹É¬Íפ¬¤Ê¤¯¤Ê¤ë¡£
298 .\"O Set the close-on-exec
299 .\"O .RB ( FD_CLOEXEC )
300 .\"O flag on the new file descriptor.
301 .\"O See the description of the
305 .\"O for reasons why this may be useful.
306 ¿·¤·¤¤¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ·¤Æ
310 ¤³¤Î¥Õ¥é¥°¤¬Ìò¤ËΩ¤ÄÍýͳ¤Ë¤Ä¤¤¤Æ¤Ï¡¢
314 ¥Õ¥é¥°¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£
315 .\"O .SH "RETURN VALUE"
318 .\"O these system calls return a nonnegative integer that is a descriptor
319 .\"O for the accepted socket.
320 .\"O On error, \-1 is returned, and
322 .\"O is set appropriately.
323 À®¸ù¤·¤¿¾ì¹ç¡¢¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï
324 ¼õ¤±ÉÕ¤±¤¿¥½¥±¥Ã¥È¤Î¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤¢¤ëÈóÉé¤ÎÀ°¿ôÃͤòÊÖ¤¹¡£
325 ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¡¢
328 .\"O .SS "Error Handling"
334 .\"O passes already-pending network errors on the new socket
335 .\"O as an error code from
341 ¤Ï¡¢¿·¤·¤¤¥½¥±¥Ã¥È¤Ë¤ª¤±¤ë¡¢È¯À¸ºÑ¤ß¤Î¥Í¥Ã¥È¥ï¡¼¥¯¥¨¥é¡¼¤ò
343 ¤«¤é¤Î¥¨¥é¡¼¥³¡¼¥É¤È¤·¤ÆÅϤ¹¡£
344 .\"O This behavior differs from other BSD socket
345 .\"O implementations.
346 .\"O For reliable operation the application should detect
347 .\"O the network errors defined for the protocol after
353 .\"O In case of TCP/IP these are
354 ¤³¤Î¿¶Éñ¤¤¤Ï BSD ¥½¥±¥Ã¥È¤Î¼ÂÁõ¤È¤Ï°Û¤Ê¤ë¡£
355 ¿®ÍêÀ¤Î¹â¤¤Æ°ºî¤ò¹Ô¤¦¤¿¤á¤Ë¤Ï¡¢
356 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¥×¥í¥È¥³¥ë¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥Í¥Ã¥È¥ï¡¼¥¯¥¨¥é¡¼¤Î¸¡ÃΤò
358 ¤Î¤¢¤È¤Ë¹Ô¤¤¡¢¤½¤ì¤é¤Î¥¨¥é¡¼¤ò
360 ¤ÈƱ¤¸¤è¤¦¤Ë°·¤¤¡¢ºÆ»î¹Ô (retry) ¤ò¹Ô¤¦¤Ù¤¤Ç¤¢¤ë¡£
363 .\"O .BR ENOPROTOOPT ,
366 .\"O .BR EHOSTUNREACH ,
367 .\"O .BR EOPNOTSUPP ,
369 .\"O .BR ENETUNREACH .
370 TCP/IP ¤Ç¤Ï¡¢°Ê²¼¤Î¥¨¥é¡¼¤¬³ºÅö¤¹¤ë:
382 .\"O .BR EAGAIN " or " EWOULDBLOCK
383 .BR EAGAIN " ¤Þ¤¿¤Ï " EWOULDBLOCK
384 .\" Actually EAGAIN on Linux
385 .\"O The socket is marked nonblocking and no connections are
386 .\"O present to be accepted.
387 .\"O POSIX.1-2001 allows either error to be returned for this case,
388 .\"O and does not require these constants to have the same value,
389 .\"O so a portable application should check for both possibilities.
390 ¥½¥±¥Ã¥È¤¬ÈóÄä»ß¤Ë¤Ê¤Ã¤Æ¤¤¤Æ¡¢
391 ¤«¤Ä¼õÉÕ¤±ÂоݤÎÀܳ¤¬Â¸ºß¤·¤Ê¤¤¡£
392 POSIX.1-2001 ¤Ï¡¢¤³¤Î¾ì¹ç¤Ë¤É¤Á¤é¤Î¥¨¥é¡¼¤òÊÖ¤¹¤³¤È¤âǧ¤á¤Æ¤ª¤ê¡¢
393 ¤³¤ì¤é 2 ¤Ä¤ÎÄê¿ô¤¬Æ±¤¸Ãͤò»ý¤Ä¤³¤È¤âµá¤á¤Æ¤¤¤Ê¤¤¡£
394 ¤·¤¿¤¬¤Ã¤Æ¡¢°Ü¿¢À¤¬É¬Íפʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢Î¾Êý¤Î²ÄǽÀ¤ò
398 .\"O The descriptor is invalid.
399 ¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬ÉÔÀµ¡£
402 .\"O A connection has been aborted.
408 .\"O argument is not in a writable part of the user address space.
410 °ú¤¿ô¤¬¥æ¡¼¥¶¥¢¥É¥ì¥¹¶õ´Ö¤Î½ñ¤¹þ¤ß²ÄǽÎΰè¤Ë¤Ê¤¤¡£
413 .\"O The system call was interrupted by a signal that was caught
414 .\"O before a valid connection arrived; see
416 ͸ú¤ÊÀܳ¤¬ÅþÃ夹¤ëÁ°¤ËÊ᪤µ¤ì¤¿¥·¥°¥Ê¥ë¤Ë¤è¤Ã¤Æ
417 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬ÃæÃǤµ¤ì¤¿¡£
422 .\"O Socket is not listening for connections, or
424 .\"O is invalid (e.g., is negative).
425 ¥½¥±¥Ã¥È¤¬ÀܳÂÔ¤Á¾õÂ֤ǤϤʤ¤¡£¤â¤·¤¯¤Ï¡¢
427 ¤¬ÉÔÀµ¤Ç¤¢¤ë (Î㤨¤Ð¡¢Éé¤Î¾ì¹ç¤Ê¤É)¡£
430 .\"O .RB ( accept4 ())
431 .\"O invalid value in
435 ¤ËÉÔÀµ¤ÊÃͤ¬»ØÄꤵ¤ì¤Æ¤¤¤ë¡£
438 .\"O The per-process limit of open file descriptors has been reached.
439 1¥×¥í¥»¥¹¤¬¥ª¡¼¥×¥ó¤Ç¤¤ë¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¿ô¤Î¾å¸Â¤Ë㤷¤¿¡£
442 .\"O The system limit on the total number of open files has been reached.
443 ¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤ÎÁí¿ô¤¬¥·¥¹¥Æ¥àÁ´ÂΤξå¸Â¤Ë㤷¤¿¡£
445 .BR ENOBUFS ", " ENOMEM
446 .\"O Not enough free memory.
447 .\"O This often means that the memory allocation is limited by the socket buffer
448 .\"O limits, not by the system memory.
450 ¿¤¯¤Î¾ì¹ç¤Ï¡¢¥·¥¹¥Æ¥à¥á¥â¥ê¤¬Â¤ê¤Ê¤¤¤ï¤±¤Ç¤Ï¤Ê¤¯¡¢
451 ¥½¥±¥Ã¥È¥Ð¥Ã¥Õ¥¡¤ÎÂ礤µ¤Ë¤è¤ë¥á¥â¥ê³ä¤êÅö¤Æ¤ÎÀ©¸Â¤Ç¤¢¤ë¡£
454 .\"O The descriptor references a file, not a socket.
455 ¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¥½¥±¥Ã¥È¤Ç¤Ï¤Ê¤¯¥Õ¥¡¥¤¥ë¤ò»²¾È¤·¤Æ¤¤¤ë¡£
458 .\"O The referenced socket is not of type
459 .\"O .BR SOCK_STREAM .
460 »²¾È¤·¤Æ¤¤¤ë¥½¥±¥Ã¥È¤Î·¿¤¬
468 .\"O In addition, Linux
471 ¾åµ¤Ë²Ã¤¨¤Æ¡¢Linux ¤Î
473 ¤Ï°Ê²¼¤Î¥¨¥é¡¼¤Ç¼ºÇÔ¤¹¤ë:
476 .\"O Firewall rules forbid connection.
477 ¥Õ¥¡¥¤¥¢¥¦¥©¡¼¥ë¤Î¥ë¡¼¥ë¤Ë¤è¤êÀܳ¤¬¶Ø»ß¤µ¤ì¤¿¡£
479 .\"O In addition, network errors for the new socket and as defined
480 .\"O for the protocol may be returned.
481 .\"O Various Linux kernels can
482 .\"O return other errors such as
483 ¤³¤Î¾¤Ë¡¢¿·¤·¤¤¥½¥±¥Ã¥È¤ËÂФ¹¤ë¥Í¥Ã¥È¥ï¡¼¥¯¥¨¥é¡¼¤¬ÊÖ¤µ¤ì¤ë¤³¤È¤â¤¢¤ë¡£
484 ¤³¤ì¤é¤Ï¤½¤ì¤¾¤ì¤Î¥×¥í¥È¥³¥ë¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
485 ¤¤¤í¤¤¤í¤Ê Linux ¥«¡¼¥Í¥ë¤Ç¤Ï¡¢
486 °Ê²¼¤Ë¼¨¤¹¤è¤¦¤Ê¥¨¥é¡¼¤òÊÖ¤¹¤³¤È¤â¤¢¤ë¡£
488 .BR ESOCKTNOSUPPORT ,
489 .BR EPROTONOSUPPORT ,
493 .\"O may be seen during a trace.
495 ¤¬¥È¥ì¡¼¥¹¤ÎºÇÃæ¤Ë¸½¤ì¤ë¤³¤È¤â¤¢¤ë¡£
500 .\"O system call is available starting with Linux 2.6.28;
501 .\"O support in glibc is available starting with version 2.10.
503 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux 2.6.28 °Ê¹ß¤ÇÍøÍѲÄǽ¤Ç¤¢¤ë¡£
504 glibc ¤Ç¤Î¥µ¥Ý¡¼¥È¤Ï¥Ð¡¼¥¸¥ç¥ó 2.10 °Ê¹ß¤ÇÍøÍѲÄǽ¤Ç¤¢¤ë¡£
505 .\"O .SH CONFORMING TO
511 .\"O first appeared in 4.2BSD).
512 .\"O .\" The BSD man page documents five possible error returns
513 .\"O .\" (EBADF, ENOTSOCK, EOPNOTSUPP, EWOULDBLOCK, EFAULT).
514 .\"O .\" POSIX.1-2001 documents errors
515 .\"O .\" EAGAIN, EBADF, ECONNABORTED, EINTR, EINVAL, EMFILE,
516 .\"O .\" ENFILE, ENOBUFS, ENOMEM, ENOTSOCK, EOPNOTSUPP, EPROTO, EWOULDBLOCK.
517 .\"O .\" In addition, SUSv2 documents EFAULT and ENOSR.
522 ¤Ï 4.2BSD ¤Ç½é¤á¤Æ¼ÂÁõ¤µ¤ì¤¿).
523 .\" BSD ¤Î man ¥Ú¡¼¥¸¤Ë¤Ï¡¢ 5 ¤Ä¤Î¥¨¥é¡¼¤¬ÊÖ¤µ¤ì¤¦¤ë¤È½ñ¤«¤ì¤Æ¤¤¤ë
524 .\" (EBADF, ENOTSOCK, EOPNOTSUPP, EWOULDBLOCK, EFAULT)¡£
525 .\" POSIX.1-2001 ¤Ç¤Ï¡¢
526 .\" EAGAIN, EBADF, ECONNABORTED, EINTR, EINVAL, EMFILE,
527 .\" ENFILE, ENOBUFS, ENOMEM, ENOTSOCK, EOPNOTSUPP, EPROTO, EWOULDBLOCK
528 .\" ¤¬¥¨¥é¡¼¤È¤·¤Æµ½Ò¤µ¤ì¤Æ¤¤¤ë¡£
529 .\" ¤µ¤é¤Ë¡¢SUSv2 ¤Ë¤Ï EFAULT, ENOSR ¤âµ½Ò¤µ¤ì¤Æ¤¤¤ë¡£
532 .\"O is a nonstandard Linux extension.
534 ¤ÏÈóɸ½à¤Î Linux ¤Ë¤è¤ë³ÈÄ¥¤Ç¤¢¤ë¡£
536 .\"O On Linux, the new socket returned by
538 .\"O does \fInot\fP inherit file status flags such as
542 .\"O from the listening socket.
543 .\"O This behavior differs from the canonical BSD sockets implementation.
544 .\"O .\" Some testing seems to show that Tru64 5.1 and HP-UX 11 also
545 .\"O .\" do not inherit file status flags -- MTK Jun 05
546 .\"O Portable programs should not rely on inheritance or noninheritance
547 .\"O of file status flags and always explicitly set all required flags on
548 .\"O the socket returned from
552 ¤¬ÊÖ¤¹¿·¤·¤¤¥½¥±¥Ã¥È¤Ï listen ¤ò¹Ô¤Ã¤Æ¤¤¤ë¥½¥±¥Ã¥È¤Î
557 ¤Ê¤É) ¤ò·Ñ¾µ¡Ö¤·¤Ê¤¤¡×¡£
558 ¤³¤ÎÆ°ºî¤Ïɸ½àŪ¤Ê BSD ¥½¥±¥Ã¥È¤Î¼ÂÁõ¤È¤Ï°Û¤Ê¤Ã¤Æ¤¤¤ë¡£
559 .\" ¤¤¤¯¤Ä¤«¼Â¸³¤·¤¿¤È¤³¤í¤Ç¤Ï Tru64 5.1 ¤È HP-UX 11 ¤â
560 .\" ¥Õ¥¡¥¤¥ë¾õÂ֥ե饰¤ò·Ñ¾µ¤·¤Ê¤¤¤è¤¦¤Ç¤¢¤ë¡£ -- MTK Jun 05
561 °Ü¿¢À¤ò¹Íθ¤·¤¿¥×¥í¥°¥é¥à¤Ç¤Ï¥Õ¥¡¥¤¥ë¾õÂ֥ե饰¤¬·Ñ¾µ¤µ¤ì¤ë¤«¤É¤¦¤«¤Ï
564 ¤¬ÊÖ¤·¤¿¥½¥±¥Ã¥È¤ËÂФ·¤ÆÁ´¤Æ¤ÎɬÍפʥե饰¤òÌÀ¼¨Åª¤ËÀßÄꤹ¤ë¤è¤¦¤Ë
569 .\"O POSIX.1-2001 does not require the inclusion of
570 .\"O .IR <sys/types.h> ,
571 .\"O and this header file is not required on Linux.
572 .\"O However, some historical (BSD) implementations required this header
573 .\"O file, and portable applications are probably wise to include it.
576 ¤Î¥¤¥ó¥¯¥ë¡¼¥É¤Ïɬ¿Ü¤È¤µ¤ì¤Æ¤ª¤é¤º¡¢
577 Linux ¤Ç¤Ï¤³¤Î¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤ÏɬÍפǤϤʤ¤¡£
578 ¤·¤«¤·¡¢Îò»ËŪ¤Ë¤Ï¡¢¤¤¤¯¤Ä¤«¤Î¼ÂÁõ (BSD ·Ï) ¤Ç¤³¤Î¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤¬
579 ɬÍפǤ¢¤ê¡¢°Ü¿¢À¤¬É¬Íפʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¤³¤Î¥Õ¥¡¥¤¥ë¤ò
580 ¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¤Î¤¬¸ÌÀ¤Ç¤¢¤í¤¦¡£
582 .\"O There may not always be a connection waiting after a
588 .\"O return a readability event because the connection might have been
589 .\"O removed by an asynchronous network error or another thread before
597 ¤¬Æɤ߹þ¤ß²Äǽ¥¤¥Ù¥ó¥È¤òÊÖ¤·¤¿¸å¤Ë¡¢
598 ɬ¤º¤·¤âÂÔµ¡Ãæ¤ÎÀܳ¤¬¤¢¤ë¤È¤Ï¸Â¤é¤Ê¤¤¡£
601 ¤¬¸Æ¤Ð¤ì¤ëÁ°¤Ë¡¢ÈóƱ´üŪ¤Ê¥Í¥Ã¥È¥ï¡¼¥¯¥¨¥é¡¼¤ä
602 ¾¤Î¥¹¥ì¥Ã¥É¤«¤é¸Æ¤Ð¤ì¤¿ (Ê̤Î) accept ¤Ë¤è¤Ã¤Æ
603 ºï½ü¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
604 .\"O If this happens then the call will block waiting for the next
605 .\"O connection to arrive.
608 .\"O never blocks, the passed socket
610 .\"O needs to have the
613 .\"O .BR socket (7)).
616 ¸Æ¤Ó½Ð¤·¤ÏÄä»ß (block) ¤·¡¢¼¡¤ÎÀܳ¤ÎÅþÃå¤òÂÔ¤Á¤Ä¤Å¤±¤ë¡£
618 ¤ËÄä»ß¤ò¹Ô¤ï¤»¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¤Ë¤Ï¡¢°ú¤¿ô¤ËÅϤ¹¥½¥±¥Ã¥È
622 ¥Õ¥é¥°¤ò¥»¥Ã¥È¤·¤Æ¤ª¤¯É¬Íפ¬¤¢¤ë
625 .\"O .SS The socklen_t type
627 .\"O The third argument of
629 .\"O was originally declared as an \fIint *\fP (and is that under libc4 and libc5
630 .\"O and on many other systems like 4.x BSD, SunOS 4, SGI); a POSIX.1g draft
631 .\"O standard wanted to change it into a \fIsize_t *\fP, and that is what it is
634 ¤ÎÂè 3 °ú¤¿ô¤Ï¡¢¤â¤È¤â¤È \fIint *\fP ¤ÈÀë¸À¤µ¤ì¤Æ¤¤¤¿
635 (libc4 ¤ä libc5, 4.x BSD, SunOS 4, SGI ¤Ê¤É¿¤¯¤Î¥·¥¹¥Æ¥à¤Ç¤Ï¤½¤¦¤Ê¤Ã¤Æ¤¤¤ë)¡£
636 POSIX.1g draft ɸ½à¤Ï¡¢
637 ¤³¤ì¤ò \fIsize_t *\fP ¤ËÊѹ¹¤·¤è¤¦¤È¤·¡¢SunOS 5 ¤Ç¤Ï¤½¤¦Àë¸À¤µ¤ì¤Æ¤¤¤ë¡£
638 .\"O Later POSIX drafts have \fIsocklen_t *\fP,
639 .\"O and so do the Single Unix Specification and glibc2.
640 ¸å¤Ë POSIX drafts ¤Ë¤Ï \fIsocklen_t *\fP ¤¬´Þ¤Þ¤ì¤ë¤è¤¦¤Ë¤Ê¤ê¡¢
641 Single Unix Specification ¤ä glibc2 ¤Ç¤Ï¤³¤Î¤è¤¦¤ËÀë¸À¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£
642 .\"O Quoting Linus Torvalds:
643 Linus Torvald ¤Îȯ¸À¤ò°úÍѤ¹¤ë:
645 .\" .I fails: only italicizes a single line
646 .\"O "_Any_ sane library _must_ have "socklen_t" be the same size
648 .\"O Anything else breaks any BSD socket layer stuff.
649 .\"O POSIX initially \fIdid\fP make it a size_t, and I (and hopefully others, but
650 .\"O obviously not too many) complained to them very loudly indeed.
651 .\"O Making it a size_t is completely broken, exactly because size_t very
652 .\"O seldom is the same size as "int" on 64-bit architectures, for example.
654 .\"O \fIhas\fP to be the same size as "int" because that's what the BSD socket
656 .\"O Anyway, the POSIX people eventually got a clue, and created "socklen_t".
657 .\"O They shouldn't have touched it in the first place, but once they did
658 .\"O they felt it had to have a named type for some unfathomable reason
659 .\"O (probably somebody didn't like losing face over having done the original
660 .\"O stupid thing, so they silently just renamed their blunder)."
661 ¡Ö¤Þ¤È¤â¤Ê¥é¥¤¥Ö¥é¥ê¤òºî¤ê¤¿¤±¤ì¤Ð¡¢ "socklen_t"
662 ¤Î¥µ¥¤¥º¤Ï int ¤ÈƱ¤¸¤Ë¤·¤Ê¤¤ã¤Ê¤é¤Ê¤¤¡£
663 ¤µ¤â¤Ê¤¤¤È BSD ¥½¥±¥Ã¥ÈÁؤòÇ˲õ¤¹¤ë¤³¤È¤Ë¤Ê¤Ã¤Á¤ã¤¦¡£
664 POSIX ¤ÏºÇ½é¤³¤¤¤Ä¤ò size_t ¤Ë¤·¤¿¤ó¤Ç¡¢
665 ¤Ü¤¯¤ÏÈà¤é¤Ëʸ¶ç¤ò¤¬¤Ê¤ê¤¿¤Æ¤¿
666 (¿ʬ¤½¤¦¤¤¤¦¿Í¤Ï¾¤Ë¤â¤¤¤¿¤È»×¤¦¡£Â¿¤¯¤Ï¤Ê¤«¤Ã¤¿¤è¤¦¤À¤±¤É)¡£
667 ¤³¤¤¤Ä¤ò size_t ¤Ë¤¹¤ë¤Î¤Ï´°Á´¤Ë¤¤¤«¤ì¤Æ¤ë¡£
668 Î㤨¤Ð 64 ¥Ó¥Ã¥È¥¢¡¼¥¥Æ¥¯¥Á¥ã¤Ç¤Ï¡¢
669 size_t ¤¬ "int" ¤ÈƱ¤¸¥µ¥¤¥º¤À¤Ê¤ó¤Æ¤³¤È¤Ï¤Û¤È¤ó¤É¤Ê¤¤¤«¤é¤Í¡£
670 ¤³¤Î¥µ¥¤¥º¤Ï "int" ¤È Ʊ¤¸¤Ç¤Ê¤¤ã¡Ø¥À¥á¡Ù¤Ê¤ó¤À¡£
671 BSD ¥½¥±¥Ã¥È¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ã¤Æ¤¤¤¦¤Î¤Ï¤½¤¦¤¤¤¦¤â¤Î¤Ê¤ó¤À¤«¤é¡£
672 ¤Þ¤¢¤È¤â¤«¤¯ POSIX ¤Î¿Í¤¿¤Á¤â¡¢
673 "socklen_t" ¤òºî¤ë¤È¤¤¤¦²ò·èºö¤ò¤Ê¤ó¤È¤«¤Ò¤Í¤ê½Ð¤·¤¿¡£
674 ¤½¤â¤½¤âºÇ½é¤«¤éÊü¤Ã¤Æ¤ª¤±¤ÐÎɤ«¤Ã¤¿¤ó¤À¤¬¡¢
676 ̾Á°ÉÕ¤¤Î·¿¤ò»ý¤¿¤»¤Ê¤¤ã¤Ê¤é¤Ê¤¤¡¢¤È»×¤Ã¤¿¤ß¤¿¤¤¤À¤Í¡£
677 ¤Ê¤ó¤Ç¤«¤Ï¤ï¤«¤ó¤Ê¤¤¤±¤É
678 (¤¤Ã¤ÈºÇ½é¤Ë¤ä¤Ã¤Á¤Þ¤Ã¤¿Çϼ¯¤Ê´Ö°ã¤¤¤Ç´é¤ò¤Ä¤Ö¤·¤¿¤¯¤Ê¤«¤Ã¤¿¤«¤é¡¢
679 ¤³¤Ã¤½¤ê̾Á°¤òÉÕ¤±Âؤ¨¤Æ¼«Ê¬¤¿¤Á¤ÎÂ缺ÇÔ¤ò¤´¤Þ¤«¤½¤¦¤È¤·¤¿¤ó¤À¤í¤¦)¡£¡×