1 .\" Copyright (C) 2011 by Andi Kleen <andi@firstfloor.org>
2 .\" and Copyright (c) 2011 by Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .TH RECVMMSG 2 2011-10-04 "Linux" "Linux Programmer's Manual"
26 recvmmsg \- receive multiple messages on a socket
29 .B "#define _GNU_SOURCE"
30 .BI "#include <sys/socket.h>"
32 .BI "int recvmmsg(int " sockfd ", struct mmsghdr *" msgvec \
33 ", unsigned int " vlen ","
35 .BI " unsigned int " flags ", struct timespec *" timeout ");"
40 system call is an extension of
42 that allows the caller to receive multiple messages from a socket
43 using a single system call.
44 (This has performance benefits for some applications.)
45 A further extension over
47 is support for a timeout on the receive operation.
51 argument is the file descriptor of the socket to receive data from.
55 argument is a pointer to an array of
58 The size of this array is specified in
63 structure is defined in
70 struct msghdr msg_hdr; /* Message header */
71 unsigned int msg_len; /* Number of received bytes for header */
80 structure, as described in
84 field is the number of bytes returned for the message in the entry.
85 This field has the same value as the return value of a single
91 argument contains flags ORed together.
92 The flags are the same as documented for
94 with the following addition:
99 after the first message has been received.
106 .BR clock_gettime (2))
107 defining a timeout (seconds plus nanoseconds) for the receive operation.
112 then the operation blocks indefinitely.
118 messages have been received
119 or until the timeout expires.
120 A nonblocking call reads as many messages as are available
121 (up to the limit specified by
123 and returns immediately.
127 successive elements of
129 are updated to contain information about each received message:
131 contains the size of the received message;
134 are updated as described in
136 The return value of the call indicates the number of elements of
138 that have been updated.
142 returns the number of messages received in
144 on error, \-1 is returned, and
146 is set to indicate the error.
150 In addition, the following error can occur:
158 system call was added in Linux 2.6.32.
159 Support in glibc was added in version 2.12.
164 .BR clock_gettime (2),