1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
.\" Copyright (c) 1983, 1990, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)accept.2 6.6 (Berkeley) 4/29/91
.\"
.\" Modified Sat Jul 24 16:42:42 1993 by Rik Faith <faith@cs.unc.edu>
.\" Modified Mon Oct 21 23:05:29 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified Sun Mar 28 21:26:46 1999 by Andries Brouwer <aeb@cwi.nl>
.\" Japanese Version Copyright (c) 1998 Shinya HANATAKA, Takeshi Hakamada
.\" all rights reserved.
.\" Translated Fri Apr 6 14:54:40 JST 1998
.\" by Shinya HANATAKA <shinya@abyss.rim.or.jp>
.\" Takeshi Hakamada <hakamada@nsg.sgi.com>
.\"
.\"WORD: socket å
.\"WORD: accept դ
.\"WORD: bind դ
.\"WORD: listen Ԥ
.\"WORD: queue 塼
.\"WORD: file descriptor ե롦ǥץ
.\"WORD: non-blocking ֥å
.\"WORD: communication layer ̿
.\"WORD: value-result parameter ͡ξѰ
.\"WORD: confirmation ³ǧ
.\"WORD: dequeue 塼Ф
.\"WORD: rejection ³
.\"
.TH ACCEPT 2 "24 July 1993" "BSD Man Page" "Linux Programmer's Manual"
.SH ̾
accept \- å(socket)ؤ³դ(accept)
.SH
.B #include <sys/types.h>
.sp
.B #include <sys/socket.h>
.sp
.BI "int accept(int " s ", struct sockaddr *" addr ", socklen_t *" addrlen ");"
.SH
.I s
ϡ
.BR socket (2)
ˤä줿åȤǡ
.BR bind (2)
ˤäƥɥ쥹˷դ(bind)롣
ޤ
.BR listen (2)
ȯԤ³Ԥ(listen)褦ˤʤ롣
.B accept
ؿϡαȤʤäƤ³Υ塼(queue)ǽ³Ф
.I s
Ʊ°äåȤơΥåȤ˿
ե롦ǥץ(file descriptor)Ƥ롣
塼αȤʤäƤ³ʤ֥å(non-blocking)
Ƥʤ硢
.B accept
³ȯޤǸƤӽФ֥å롣
åȤ֥åƤơα
³塼̵硢
.B accept
ϲ˼褦ʥ顼֤դåȤ
ʾ³뤳Ȥϵʤ
Υå
.I s
ϥץޤޤȤʤ롣
.I addr
ϡ̿(communication layer)ȤƤΤƤ褦ˡ
³ΤΥɥ쥹äƤѰǤ롣
.I addr
ΤʥեޥåȤ̿ԤƤɥᥤˤä
ꤵ롣
.I addrlen
ϡ͡ξѰ(value-result parameter)Ǥ롣֤Ǥϡ
.IR addr
ˤäƻؤΰ礭äƤ롣
ˤϡ֤줿ɥ쥹μºݤĹ(byteñ)롣
θƤӽФϡ³ظ(connection-based)Υåȷ
ˤƻѤ롣ߤǤϡ
.BR SOCK_STREAM
ȤȤ˻Ѥ롣
.B accept
ѤŪǡåȤɤѤȤ
.BR select (2)
뤳ȤǽǤ롣
.B ISO
.BR DATAKIT
Τ褦ˡŪ³ǧ(confirmation)᤹褦ʥץȥˤƤϡ
.B accept
ǹԤϡñ˼³塼Ф(dequeue)ǡ
³ǧϴޤޤʤ³ǧϡե롦ǥץ
Ǥ̾ɤꡢߤκݤ˹Ԥ롣
³(rejection)Ͽե롦ǥץĤ뤳Ȥˤä
Ԥ롣
.I msg_iovlen
0
.IR msg_controllen
0ꤷ
.BR recvmsg (2)
ȯԤ뤫
.BR getsockopt (2)
ȯԤ뤳Ȥˤäơ
³ǧڤ˥桼³ǡ뤳ȤǤ롣
Ʊͤˡ
ȥΤߤͿ
.BR sendmsg (2)
ƤӽФ
.BR setsockopt (2)
ƤӽФȤˤäƥ桼³ݾ뤳ȤǤ롣
.SH "֤"
Υϥ顼 \-1֤ϼդ줿
åȤΥǥץǤ֤ͤ
.SH 顼
.\"The BSD man page documents five possible error returns.
BSD man pageǤϰʲ˼ 5 ĤΥ顼֤ȤǤ롣
.TP
.B EBADF
ǥץ̵Ǥ롣
.TP
.B ENOTSOCK
ǥץϥåȤǤϤʤեȤƤ롣
.TP
.B EOPNOTSUPP
ȤƤ륽åȤη
.BR SOCK_STREAM
ǤϤʤ
.TP
.B EFAULT
.I addr
桼ɥ쥹֤ν߲ǽΰȤƤʤ
.TP
.B EWOULDBLOCK
åȤ֥åƤơդ³ʤ
.LP
¾ˡ¿LinuxͥǤϰʲ˼褦ʥ顼֤ȤǤ롣
.BR EMFILE ,
.BR EINVAL ,
.BR ENOSR ,
.BR ENOBUFS ,
.BR EAGAIN ,
.BR EPERM ,
.BR ECONNABORTED ,
.BR ESOCKTNOSUPPORT ,
.BR EPROTONOSUPPORT ,
.BR ETIMEDOUT ,
.BR ERESTARTSYS .
.SH
SVr4, 4.4BSD (
.B accept
ؿBSD 4.2ǽƼ줿)
IRIX Ǥ EMFILE ENFILE ɲå顼ȤƵҤƤ롣
Solaris Ǥ EINTR, ENODEV, ENOMEM, ENOSR, EPROTO ɲå顼Ȥ
ҤƤ롣
.SH
.B accept
λܤΰϡ libc4, libc5 BSD 4.*, SunOS 4, SGI ʤ¿
ΥƥǸ `int *' ƤPOSIX 1003.1g ɥեɸϡ
`size_t *' ѹ褦ȤSunOS 5 ǤϤƤ롣
POSIX ɥեȤ `socklen_t *' ѹ졢Single Unix Specification
glibc2 ǤƱͤ褦ˤʤä
Linus Torvaldȯ: `ʤޤȤʥ饤֥ "socklen_t"
int ΥƱǤʤФʤʤۤʤ BSD åؤ
˲뤳Ȥˤʤ롣
κ POSIX size_t ˤ(ȡۤ¿Ϥʤͭ˾ˤ
¾οͤ) POSIX ФƼºݤʤ礭Ҥ٤㤨 size_t
64ӥåȥƥ "int" ƱǤ뤳Ȥ˵ʤȤ
뤿ᡢsize_t ˤ뤳Ȥϴ˴ְäƤ롣BSD åȥե
Ʊͤ "int" ƱǤʤФʤʤ
ˤƤ⡢POSIX λͺ˴ؤäͤϺǽŪˤΰոѤ
"socklen_t" äϤϤᤫѹ٤Ǥʤäѹ
塢餫ԲIJͳˤꡢ̾äʤ
ʤʤȴ(餯ϼѹȤ餫ˤʤ뤳Ȥˤ
ܤȤäˡۤ˷̾ѹΤǤ롣)'
.SH "Ϣ"
.BR bind "(2), " connect "(2), " listen "(2), " select "(2), " socket (2)
|