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 .\" FIXME: This page could be improved with an example program.
26 .TH RECVMMSG 2 2011-10-04 "Linux" "Linux Programmer's Manual"
28 recvmmsg \- receive multiple messages on a socket
31 .B "#define _GNU_SOURCE"
32 .BI "#include <sys/socket.h>"
34 .BI "int recvmmsg(int " sockfd ", struct mmsghdr *" msgvec \
35 ", unsigned int " vlen ","
37 .BI " unsigned int " flags ", struct timespec *" timeout ");"
42 system call is an extension of
44 that allows the caller to receive multiple messages from a socket
45 using a single system call.
46 (This has performance benefits for some applications.)
47 A further extension over
49 is support for a timeout on the receive operation.
53 argument is the file descriptor of the socket to receive data from.
57 argument is a pointer to an array of
60 The size of this array is specified in
65 structure is defined in
72 struct msghdr msg_hdr; /* Message header */
73 unsigned int msg_len; /* Number of received bytes for header */
82 structure, as described in
86 field is the number of bytes returned for the message in the entry.
87 This field has the same value as the return value of a single
93 argument contains flags ORed together.
94 The flags are the same as documented for
96 with the following addition:
101 after the first message has been received.
108 .BR clock_gettime (2))
109 defining a timeout (seconds plus nanoseconds) for the receive operation.
114 then the operation blocks indefinitely.
120 messages have been received
121 or until the timeout expires.
122 A nonblocking call reads as many messages as are available
123 (up to the limit specified by
125 and returns immediately.
129 successive elements of
131 are updated to contain information about each received message:
133 contains the size of the received message;
136 are updated as described in
138 The return value of the call indicates the number of elements of
140 that have been updated.
144 returns the number of messages received in
146 on error, \-1 is returned, and
148 is set to indicate the error.
152 In addition, the following error can occur:
160 system call was added in Linux 2.6.32.
161 Support in glibc was added in version 2.12.
166 .BR clock_gettime (2),