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 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
|
.\" Copyright (c) 1983, 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.
.\"
.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
.\" Modified 1996-10-22 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified Oct 1998 by Andi Kleen
.\" Modified Oct 2003 by aeb
.\" Modified 2004-07-01 by mtk
.\"
.\" Japanese Version Copyright (c) 1996 HANATAKA Shinya all rights reserved.
.\" Translated 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated 1999-08-15, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated 2000-01-13, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2001-01-30, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2005-03-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2005-12-26, Akihiro MOTOKI
.\" Updated 2006-04-15, Akihiro MOTOKI, Catch up to LDP v2.29
.\"
.\"WORD: socket å
.\"WORD: message å
.\"WORD: protocol ץȥ
.\"WORD: non-blocking I/O I/O
.\"WORD: block (block)
.\"WORD: out-of-band Ӱ賰
.\"WORD: descriptor ǥץ
.\"WORD: parameter ѥ
.\"WORD: queue 塼
.\"WORD: buffer Хåե
.\"WORD: routing 롼ƥ
.\"WORD: congestion
.\"
.TH SEND 2 2004-07-01 "Linux 2.6.7" "Linux Programmer's Manual"
.SH ̾
send, sendto, sendmsg \- åȤإå
.SH
.B #include <sys/types.h>
.br
.B #include <sys/socket.h>
.sp
.BI "ssize_t send(int " s ", const void *" buf ", size_t " len ,
.BI "int " flags );
.br
.BI "ssize_t sendto(int " s ", const void *" buf ", size_t " len ,
.BI "int " flags ", const struct sockaddr *" to ", socklen_t " tolen );
.br
.BI "ssize_t sendmsg(int " s ", const struct msghdr *" msg ,
.BI "int " flags );
.SH
ƥॳ
.BR send (),
.BR sendto (),
.BR sendmsg ()
ϡ⤦ΥåȤإåžΤ˻Ѥ롣
.PP
.BR send ()
ϡåȤ
.I "³줿 (connected)"
֤ˤˤΤѤǤ
(Ĥޤꡢɤ뤫ϴΤǤ)
.BR send ()
.BR write ()
ΰ㤤ϡ
.I flags
뤫ɤǤ롣
.I flags
0 ξ硢
.BR send ()
.BR write ()
Ǥ롣
ޤ
.RI send( s , buf , len , flags )
.RI sendto( s , buf , len , flags ,NULL,0)
Ǥ롣
.PP
.I s
ϡǡѥåȤΥե롦ǥץǤ롣
.PP
.BR sendto ()
ϡ³ (connection-mode) Υå (SOCK_STREAM, SOCK_SEQPACKET)
Ѥ줿硢
.I to
.I tolen
̵뤵 (ơΰ NULL 0 Ǥʤ EISCONN 顼֤)
ޤåȤºݤˤ³Ƥʤäˤ ENOTCONN 顼֤롣
³ΥåȰʳǻѤ줿ϡ³Υɥ쥹
.I to
Ϳ졢Υ
.I tolen
ǻꤵ롣
.BR sendmsg ()
Ǥϡ³Υɥ쥹
.I msg.msg_name
Ϳ졢Υ
.I msg.msg_namelen
ǻꤵ롣
.PP
.BR send ()
.BR sendto ()
Ǥϡå
.I buf
˳ǼƤꡢĹ
.I len
ǤȲᤵ롣
.BR sendmsg ()
Ǥϡå
.I msg.msg_iov
γǤؤ֤˳ǼƤ롣
.BR sendmsg ()
Ǥϡǡ (ȤƤФ) 뤳ȤǤ롣
.PP
åĹĹ뤿ˡΥåȤѤץȥǤϡ
ååȤϤ줿ޤޤη뤳ȤǤʤ硢
.B EMSGSIZE
顼֤졢Υåžʤ
.PP
.BR send ()
ǤϡμԤΤŪ˹Ԥ롣
¦ǥ顼Ф줿ϡ֤ \-1 ȤΤ롣
.PP
ååȤХåե뤳ȤǤʤ硢
.BR send ()
̾ (block) (åȤ (non-blocking) I/O ⡼
Ǥʤ)ߥ⡼ɤξˤ
.B EAGAIN
֤ĥǡǤ褦ˤʤ뤫Τ뤿ˡ
.BR select (2)
Ѥ뤳ȤǤ롣
.PP
.I flags
ѥϡʲΥե饰 (0 İʾ) ӥåñ̤¤
ȤäΤꤹ롣
.\" FIXME? MSG_PROXY ˤĤƵܤ뤳
.\" (MSG_PROXY 2.3.15 Ǥʤʤä)
.TP
.BR MSG_CONFIRM " (Linux 2.3 ʹߤΤ)"
ž˿ŸäĤޤ¦αȤؤ
Τ餻롣ؤΤʤäˤϡ̾ɤ
(˥㥹 ARP Ȥʤɤˡ) ˵ (neighbour) κƸԤ
.B SOCK_DGRAM
.B SOCK_RAW
ΥåȤФƤΤͭǡߤΤȤ IPv4 IPv6 ΤƤ롣
ܤ
.BR arp (7)
ȤΤȡ
.TP
.B MSG_DONTROUTE
ѥåȤФΤ˥ȥѤ
ľ³ƤͥåȥΥۥȤ롣
̾Υե饰Ͽ (diagnostic) 롼ƥץ
äƤΤѤ롣Υե饰ϡϩ椬Ԥץȥեߥ
ФƤΤƤ롣ѥåȥåȤˤƤʤ
.TP
.B MSG_DONTWAIT
(non-blocking) ͭˤ롣ߤ褦ʾˤ
.B EAGAIN
֤褦ˤ
.RB ( fcntl (2)
.B F_SETFL
.B O_NONBLOCK
ꤹ뤳ȤˤäƤͭˤǤ)
.TP
.B MSG_EOR
쥳ɤνλؼ
.RB ( SOCK_SEQPACKET
Τ褦ˤγǰбƤ륽åȼ̤ΤȤͭ)
.TP
.BR MSG_MORE " (Linux 2.4.4 ʹ)"
ƤӽФˤǡ뤳Ȥ
Υե饰 TCP åȤȤȤ˻Ѥ졢
TCP_CORK åȥץƱ̤
.RB ( tcp (7)
) TCP_CORK Ȥΰ㤤ϡΥե饰ȤȸƤӽФñ̤
εǽͭˤǤǤ롣
Linux 2.6 ʹߤǤϡΥե饰 UDP åȤǤ⥵ݡȤƤꡢ
Υե饰դ줿ƤΥǡĤΥǡˤޤȤ
뤳ȤͥΤ餻롣ޤȤ줿ǡϡ
Υե饰ꤻˤΥƥॳ뤬¹Ԥ줿ݤ˽
.RB ( udp (7)
˵ܤƤ륽åȥץ
.B UDP_CORK
⻲)
.TP
.B MSG_NOSIGNAL
ȥظΥåȤ¦³Ǥˡ顼Ȥ
.B SIGPIPE
ʤ褦᤹롣ξǤ
.B EPIPE
֤롣
.TP
.B MSG_OOB
.I "Ӱ賰 (out-of-band)"
ǡݡȤ륽å (㤨
.BR SOCK_STREAM )
.I Ӱ賰
ǡ롣̥ץȥ
.I Ӱ賰
ǡݡȤƤɬפ롣
.PP
.I msghdr
¤ΤƤϰʲ̤ꡣ
ƥեɤΤʵҤˤĤƤ
.BR recv (2)
ȰʲȤ뤳ȡ
.in +0.25i
.nf
struct msghdr {
void *msg_name; /* ɲäΥɥ쥹 */
socklen_t msg_namelen; /* ɥ쥹Υ */
struct iovec *msg_iov; /* scatter/gather */
size_t msg_iovlen; /* msg_iov ǿ */
void *msg_control; /* ǡ() */
socklen_t msg_controllen; /* ǡХåեĹ */
int msg_flags; /* åΥե饰 */
};
.fi
.in -0.25i
.PP
.I msg_control
.I msg_controllen
СѤ뤳ȤǤ롣
ͥ뤬ǤХåեΥåȤκĹϡ
sysctl ѥ
.B net.core.optmem_max
ͤ¤Ƥ롣
.BR socket (7)
ȡ
.\" Still to be documented:
.\" Send file descriptors and user credentials using the
.\" msg_control* fields.
.\" The flags returned in msg_flags.
.SH ֤
硢Υƥॳ줿Хȿ֤
顼ξ硢 \-1 ֤
.I errno
Ŭڤˤ롣
.SH 顼
ϥåؤȯŪʥ顼Ǥ롣ʳˡؤ
ץȥ롦⥸塼줿顼֤뤫⤷ʤ
ˤĤƤϡ줾Υޥ˥奢Ȥ뤳ȡ
.TP
.B EACCES
(Unix ɥᥤåȤϥѥ̾Ǽ̤롣)
åȡեؤνߵĤʤäѥ̾
ãޤǤΥǥ쥯ȥΤ줫Ф븡Ĥʤä
.RB ( path_resolution (2)
⻲ȤΤ)
.TP
.BR EAGAIN " ޤ " EWOULDBLOCK
åȤߤꤵƤꡢ
ᤵ줿ߤ
.TP
.B EBADF
̵ʥǥץꤵ줿
.TP
.B ECONNRESET
³³ˤꥻåȤ줿
.TP
.B EDESTADDRREQ
åȤ³ (connection-mode) ǤϤʤ
Υɥ쥹ꤵƤʤ
.TP
.B EFAULT
桼֤Ȥʥɥ쥹ѥȤƻꤵ줿
.TP
.B EINTR
ǡˡʥ뤬ȯ
.TP
.B EINVAL
ʰϤ줿
.TP
.B EISCONN
³åȤ³Ǥ˳ΩƤԤꤵƤ
(ߤΤȤξǤϡΥ顼֤뤫
Ԥλ̵꤬뤵뤫Τ줫Ȥʤ)
.TP
.B EMSGSIZE
Υåȼ
.\" (㤨 SOCK_DGRAM)
ǤϥåȤϤ줿ޤޤηǥåɬפ뤬
å礭뤿뤳ȤǤʤ
.TP
.B ENOBUFS
ͥåȥեνϥ塼դǤ롣
ŪˤϡŪ (congestion) Τ˥ե
ߤƤ뤳Ȥ̣롣
(̾Linux ǤϤΤ褦ʤȤϵʤǥХΥ塼
СեˤϥѥåȤۤäƼΤƤ)
.TP
.B ENOMEM
꤬ʤ
.TP
.B ENOTCONN
åȤ³Ƥ餺³ꤵƤʤ
.TP
.B ENOTSOCK
.I s
åȤǤʤ
.TP
.B EOPNOTSUPP
.I flags
ΤĤΥӥåȤΥåȼ̤ǤŬڤʤΤǤ롣
.TP
.B EPIPE
³ظΥåȤǥ¦ĤƤ롣
ξ硢
.B MSG_NOSIGNAL
ꤵƤʤСץˤ
.B SIGPIPE
Ʊ롣
.SH
4.4BSD, SVr4, POSIX.1-2001.
(δؿ 4.2BSD Ǻǽо줷)
POSIX.1-2001 ˤϡ
.B MSG_OOB
.B MSG_EOR
ե饰ܤƤ롣
.B MSG_CONFIRM
ե饰 Linux ǤγĥǤ롣
.SH
嵭Υץȥפ Single Unix Specification ˽äƤ롣
glibc2 ƱͤǤ롣
.I flags
4.x BSD Ǥ int Ǥꡢlibc4 libc5 Ǥ unsigned int Ǥ롣
.I len
4.x BSD libc4 Ǥ int Ǥꡢlibc5 Ǥ `size_t' Ǥ롣
.I tolen
4.x BSD libc4 libc5 Ǥ `int' Ǥ롣
.BR accept (2)
⻲Ȥ뤳ȡ
POSIX.1-2001 Ǥϡ¤
.I msghdr
Υե
.I msg_controllen
.I socklen_t
Ǥ٤ȤƤ뤬
ߤ glibc (glibc 2.4) Ǥ
.I size_t
Ǥ롣
.\" glibc bug raised 12 Mar 2006
.\" http://sourceware.org/bugzilla/show_bug.cgi?id=2448
.\" The problem is an underlying kernel issue: the size of the
.\" __kernel_size_t type used to type this field varies
.\" across architectures, but socklen_t is always 32 bits.
.SH Х
Linux ENOTCONN ֤ EPIPE ֤Ȥ롣
.SH Ϣ
.BR fcntl (2),
.BR getsockopt (2),
.BR recv (2),
.BR select (2),
.BR sendfile (2),
.BR shutdown (2),
.BR socket (2),
.BR write (2),
.BR cmsg (3),
.BR ip (7),
.BR socket (7),
.BR tcp (7),
.BR udp (7)
|