File: recv.2

package info (click to toggle)
manpages-ja 0.5.0.0.20061115-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 19,788 kB
  • ctags: 4
  • sloc: sh: 13,215; perl: 157; makefile: 117
file content (466 lines) | stat: -rw-r--r-- 13,896 bytes parent folder | download
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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
.\" 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.
.\"
.\"     $Id: recv.2,v 1.8 2001/08/15 18:00:48 hanataka Exp $
.\"
.\" Modified Sat Jul 24 00:22:20 1993 by Rik Faith <faith@cs.unc.edu>
.\" Modified Tue Oct 22 17:45:19 1996 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified 1998,1999 by Andi Kleen
.\" 2001-06-19 corrected SO_EE_OFFENDER, bug report by James Hawtin
.\"
.\" Japanese Version Copyright (c) 1996 Akira Yoshiyama
.\"         all rights reserved.
.\" Translated 1996-07-18, Akira Yoshiyama <yosshy@jedi.seg.kobe-u.ac.jp>
.\" Modified 1997-12-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Modified 1999-08-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated & Modified 2000-10-12, HAYAKAWA Hitoshi <cz8cb01@linux.or.jp>
.\"        and NAKANO Takeo <nakano@apm.seikei.ac.jp>
.\" Updated & Modified 2001-02-09, NAKANO Takeo
.\" Updated 2003-10-11, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2005-03-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2006-04-15, Akihiro MOTOKI, Catch up to LDP v2.29
.\"
.\"WORD:	ancillary data		ǡ
.\"WORD:	ancillary message	å
.\"WORD:	invalid			
.\"
.TH RECV 2 2002-12-31 "Linux Man Page" "Linux Programmer's Manual"
.SH ̾
recv, recvfrom, recvmsg \- åȤå
.SH 
.\" .B #include <sys/uio.h>
.\" .br
.nf
.B #include <sys/types.h>
.br
.B #include <sys/socket.h>
.sp
.BI "ssize_t recv(int " s ", void *" buf ", size_t " len ", int " flags );
.sp
.BI "ssize_t recvfrom(int " s ", void *" buf ", size_t " len ", int " flags , 
.BI "                 struct sockaddr *" from ", socklen_t *" fromlen );
.sp
.BI "ssize_t recvmsg(int " s ", struct msghdr *" msg ", int " flags );
.fi
.SH 
.BR recvfrom ()

.BR recvmsg ()
ϡåȤåΤ˻Ѥ롣
ޤåȤΥǡˤȤȤǤ
ΤȤåȤ³ظ (connection-oriened) ǤäƤʤƤ褤
.PP
.I from
 NULL ʳǡؤΥץȥ뤫ɥ쥹ʬ硢
.I from
ˤϤɥ쥹롣
.\" (Unix ɥᥤȥ󥿡ͥåȥɥᥤΤɤΥǡॽåȤǤ
.\" .I from
.\" ɥ쥹롣ޤUnix ɥᥤΥȥ꡼ॽåȤǤ
.\" Ʊͤ󥿡ͥåȥɥᥤΥȥ꡼ॽåȤǤ
.\" .I from
.\" ˥ɥ쥹ʤ)
.\" [嵭 AF_UNIX  AF_INET åȤ˴ؤϥͥ 2.4.18 Ǥ
.\" ưƱǤ롣 (MTK, 22 Jul 02)]

.I fromlen
ξѤΥѥ᡼ǡƤӽФˤ
.IR from 
˳ƤХåե礭Ƥ֤äƤˤϼºݤ
.I from 
˳Ǽ줿ɥ쥹礭ѹ롣
.PP
.BR recv ()
̾
.I ³Ѥߤ (connected)
å
.RB ( connect (2)
򻲾) ˤĤƤΤ߻Ѥ졢
.I from
ѥ᡼ NULL ꤷ
.BR recvfrom ()
Ǥ롣
.PP
λĤΥ롼Ϥ⡢ˤϥåĹ֤
åĹ᤮ƻꤵ줿Хåեڤʤäˤϡ
ååȤμˤäƤ;ʬΥХȤΤƤ
⤷ʤ
.PP
åȤ˼å¸ߤʤä硢
ѤΥϥå夹ޤԤġ
åȤ (nonblocking)
ꤵƤ
.RB ( fcntl (2)
򻲾)  \-1 ֤ѿ
.I errno

.B EAGAIN
ꤹ롣
μѤΥϡǡΥ׵ᤷ
ãޤԤĤΤǤϤʤ餫Υǡ
(ǡκ祵׵ᤷǤ)
.PP
.BR select (2)

.BR poll (2)
ȤäơΥǡϤȽǤǤ롣
.PP
.BR recv ()

.I flags
ˤϡʲͤ 1İʾ塢ӥåñ̤
.I OR ()
äΤꤹ:
.TP
.B MSG_DONTWAIT
 (non-blocking) ͭˤ롣
ߤ褦ʾ
.B EAGAIN
֤
.RB ( fcntl (2)

.B F_SETFL

.B O_NONBLOCK
ꤹ뤳ȤˤäƤͭˤǤ)
.TP
.B MSG_ERRQUEUE
Υե饰ꤹȡ
塼줿顼򥽥åȤΥ顼塼褦ˤʤ롣
Υ顼åȤ߹ޤϤ졢
åμ̤ϥץȥ˰¸
(IPv4 ξ
.BR IP_RECVERR )
桼ϽʬʥΥХåեѰդʤФʤʤ
å˴ؤܺ٤ʾ
.BR cmsg (3)

.BR ip (7)
򻲾ȤΤȡ
顼θȤʤäꥸʥѥåȤΥڥɤϡ
.I msg_iovec
ͳ̾ΥǡȤϤ롣
顼򵯤ǡΥꥸʥΰ襢ɥ쥹ϡ
.I msg_name
ͳǻȤǤ롣
.IP
ʥ顼ξϥɥ쥹Ϥʤ
(
.I cmsghdr

.I cmsg_len
СǥåǤ)
顼ξ
.B MSG_ERRQUIE

.I msghdr
˥åȤ롣
顼Ϥ줿ˤϡ塼äƤ뼡Υ顼˴𤤤ơ
ԤΥåȡ顼졢ΥåκݤϤ롣

.IP
Υ顼
.I sock_extended_err
¤Τ󶡤:
.in +0.25i
.nf

#define SO_EE_ORIGIN_NONE    0
#define SO_EE_ORIGIN_LOCAL   1
#define SO_EE_ORIGIN_ICMP    2
#define SO_EE_ORIGIN_ICMP6   3

struct sock_extended_err
{
    u_int32_t ee_errno;   /* error number */
    u_int8_t  ee_origin;  /* where the error originated */ 
    u_int8_t  ee_type;    /* type */
    u_int8_t  ee_code;    /* code */
    u_int8_t  ee_pad;
    u_int32_t ee_info;    /* additional information */
    u_int32_t ee_data;    /* other data */  
    /* More data may follow */ 
};

struct sockaddr *SO_EE_OFFENDER(struct sock_extended_err *);
.fi
.in -0.25i
.IP
.B ee_errno 
ˤϥ塼줿顼Υ顼ֹ椬äƤ롣
.B ee_origin
ˤϥ顼ȯΥꥸ󡦥 (origin code) äƤ롣
¾Υեɤϥץȥ¸Ǥ롣
.B SO_EE_OFFENDER
ޥϡŪʥå˼äơ
顼ȯͥåȥ֥ȤΥɥ쥹ؤΥݥ󥿤֤
ɥ쥹ξˤϡ
.B sockaddr 

.I sa_family 
С
.B AF_UNSPEC
ˤʤäƤ롣
.B sockaddr
¾ΥեɤǤ롣
顼ȯѥåȤΥڥɤ̾ΥǡȤϤ롣
.IP
ǤΥ顼ξˤϥɥ쥹Ϥʤ (
.I cmsghdr

.I cmsg_len 
СǥåǤ)
顼ä硢
.B MSG_ERRQUEUE 

.I msghdr
ꤵ롣
顼Ϥ줿ˤϡ
ԤˤʤäƤåȡ顼塼äƤ
Υ顼˴Ťƺ졢ΥåκݤϤ롣
.TP
.B MSG_OOB
Υե饰ϡ̾Υǡȥ꡼ǤϼǤʤ
Ӱ賰 (out-of-band) ǡμ׵᤹롣
ץȥˤäƤϡ
̾Υǡ塼Ƭ®ãǡ֤Τ뤬
Τ褦ʥץȥǤϤΥե饰ϻѤǤʤ
.TP
.B MSG_PEEK
Υե饰ꤹȡ
塼κǽΥǡ֤Ȥ塼ǡʤ
äơθǤ⤦ټƤӽФȡƱǡ֤뤳Ȥˤʤ롣
.TP
.B MSG_TRUNC
ѥåȤĹϤХåեĹäˤ⡢
ѥåȤμºݤĹ֤ѥåȡåȤФƤΤͭ
.TP
.B MSG_WAITALL
Υե饰ϡ׵ᤷ̤äѤΥǡ夹ޤǡ
 (block) 褦׵᤹롣
âʥꡢ顼 (disconnect) ȯꡢ
˼ǡۤʤ뷿äꤷˤϡ
׵ᤷ̤ǡʤƤ֤뤳Ȥ롣
.PP
.BR recvmsg ()
ϡľϤѥ᡼ο򸺤餹
.I msghdr
¤ΤѤ롣ι¤Τ
.I <sys/socket.h> 
ǰʲΤ褦Ƥ:
.in +0.25i
.nf

struct msghdr {
    void         *msg_name;       /* optional address */
    socklen_t     msg_namelen;    /* size of address */
    struct iovec *msg_iov;        /* scatter/gather array */
    size_t        msg_iovlen;     /* # elements in msg_iov */
    void         *msg_control;    /* ancillary data, see below */
    socklen_t     msg_controllen; /* ancillary data buffer len */
    int           msg_flags;      /* flags on received message */
};
.fi
.in -0.25i
.PP
.I msg_name

.I msg_namelen
ϡåȤ³ƤʤΥɥ쥹ꤹ롣
̾ɬפʤˤ
.I msg_name
 NULL ݥ󥿤ꤹ롣
.I msg_iov

.I msg_iovlen
եɤ
.BR readv (2)
˵ҤƤ褦ʬ/ѤΥ٥ȥ (scatter-gather locations)
ꤹ롣
.IR msg_control 
եɤ
.IR msg_controllen
Ĺ¾Υץȥå
ǡΤΥХåեؤΥݥ󥿤Ǥ롣
.BR recvmsg ()
Ƥֺݤˤϡ
.I msg_controllen

.I msg_control
ΥХåեĹƤɬפ롣
뤬֤ä硢åĹäƤ롣
.PP
åηϰʲ̤:
.in +0.25i
.nf

struct cmsghdr {
    socklen_t cmsg_len;     /* data byte count, including hdr */
    int       cmsg_level;   /* originating protocol */
    int       cmsg_type;    /* protocol-specific type */
/* followed by
    u_char    cmsg_data[]; */
};
.fi
.in -0.25i
.PP
ǡϡ
.BR cmsg (3)
줿ޥͳǤΤߥ٤Ǥ롣
.PP
򤢤ȡ Linux ϤǡΥᥫ˥
Unix åȾǤγĥ顼 IP ץ
ե롦ǥץμϤѤƤ롣
.PP
msghdr 
.I msg_flags
եɤ
.BR recvmsg ()
Υ꥿ꤵ롣ˤϤĤΥե饰롣
.TP
.B MSG_EOR
ϥ쥳ɤν (end-of-record) 򼨤
֤줿ǡʥ쥳ɤǤ뤳Ȥ򼨤 (Ūˤ
.BR SOCK_SEQPACKET 
ΥåȤǻѤ)
.TP
.B MSG_TRUNC
ǡबͿ줿Хåե礭äˡ
ǡΤϤ߽ФʬΤƤ줿Ȥ򼨤
.TP
.B MSG_CTRUNC
ǡΤΥХåե­ˡ
ǡΰΤƤ줿Ȥ򼨤
.TP
.B MSG_OOB
®ãǡӰ賰ǡȤ򼨤
.TP
.B MSG_ERRQUEUE
ǡϼʤä
åȤΥ顼塼ĥ顼Ȥ򼨤
.SH ֤
ΥϼХȿ֤
顼ξ \-1 ֤
³褬åȥ¹Ԥϡ֤ͤ 0 Ȥʤ롣
.SH 顼
ϥåؤȯŪʥ顼Ǥ롣
¾Υ顼ؤΥץȥ롦⥸塼졢
֤뤫⤷ʤ
Υޥ˥奢򻲾Ȥ뤳ȡ
.TP
.B EAGAIN
åȤ (non-blocking) ꤵƤ
ߤ褦ʾˤʤä
˻ڤ (timeout) ꤵƤ
ǡ˻ڤˤʤä
.TP
.B EBADF

.I s
ʥǥץǤ롣
.TP
.B ECONNREFUSED
⡼ȤΥۥȤǥͥåȥ³ݤ줿
(褯ͳȤƤϡ׵ᤷӥưƤʤʤɤ)
.TP
.B EFAULT
ХåեؤΥݥ󥿤ץΥɥ쥹ֳؤƤ롣
.TP
.B EINTR
ǡˡʥ뤬Ƴޤ줿
.TP
.B EINVAL
ʰϤ줿
.\" e.g., msg_namelen < 0 for recvmsg() or fromlen < 0 for recvfrom()
.TP
.B ENOMEM
.BR recvmsg ()
ΤΥ꤬ݤǤʤä
.TP
.B ENOTCONN
åȤ³ظץȥ뤬ƤƤꡢ
ޤ³Ƥʤ
.RB ( connect (2)

.BR accept (2)
򻲾ȤΤ)
.TP
.B ENOTSOCK

.I s
åȤ򻲾ȤƤʤ
.SH 
4.4BSD (δؿ 4.2BSD Ǹ줿), POSIX.1-2001
.LP
POSIX.1-2001 Ǥϡ
.BR MSG_OOB ,
.BR MSG_PEEK ,
.BR MSG_WAITALL
ե饰ܤƤ롣
.SH 
嵭Υץȥפ glibc2 ˤäƤ롣
Single Unix Specification ǤƱͤ
֤ͤη ssize_t ȤʤäƤ
( 4.x BSD  libc4  libc5  `int' ѤƤ)
.I flags
 4.x BSD Ǥ `int' libc4  libc5 Ǥ `unsigned int' Ǥ롣
.I len
 4.x BSD Ǥ `int'  libc4  libc5 Ǥ `size_t' Ǥ롣
.I fromlen
 4.x BSD, libc4, libc5 Ǥ `int *' Ǥ롣
ߤ `socklen_t *'  POSIX ȯƤ줿
.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 Ϣ
.BR fcntl (2),
.BR getsockopt (2),
.BR read (2),
.BR select (2),
.BR shutdown (2),
.BR socket (2),
.BR cmsg (3),
.BR sockatmark (3)