1RECVMMSG(2)                Linux Programmer's Manual               RECVMMSG(2)
2
3
4

NAME

6       recvmmsg - receive multiple messages on a socket
7

SYNOPSIS

9       #define _GNU_SOURCE
10       #include <sys/socket.h>
11
12       int recvmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen,
13                    unsigned int flags, struct timespec *timeout);
14

DESCRIPTION

16       The  recvmmsg()  system  call is an extension of recvmsg(2) that allows
17       the caller to receive multiple messages from a socket  using  a  single
18       system call.  (This has performance benefits for some applications.)  A
19       further extension over recvmsg(2) is  support  for  a  timeout  on  the
20       receive operation.
21
22       The  sockfd  argument  is  the file descriptor of the socket to receive
23       data from.
24
25       The msgvec argument is a pointer to an  array  of  mmsghdr  structures.
26       The size of this array is specified in vlen.
27
28       The mmsghdr structure is defined in <sys/socket.h> as:
29
30           struct mmsghdr {
31              struct msghdr msg_hdr;  /* Message header */
32              unsigned int  msg_len;  /* Number of received bytes for header */
33           };
34
35       The  msg_hdr  field  is a msghdr structure, as described in recvmsg(2).
36       The msg_len field is the number of bytes returned for  the  message  in
37       the entry.  This field has the same value as the return value of a sin‐
38       gle recvmsg(2) on the header.
39
40       The flags argument contains flags ORed together.   The  flags  are  the
41       same as documented for recvmsg(2), with the following addition:
42
43       MSG_WAITFORONE
44              Turns on MSG_DONTWAIT after the first message has been received.
45
46       The timeout argument points to a struct timespec (see clock_gettime(2))
47       defining a timeout (seconds plus nanoseconds) for  the  receive  opera‐
48       tion.  If timeout is NULL then the operation blocks indefinitely.
49
50       A  blocking  recvmmsg()  call  blocks  until  vlen  messages  have been
51       received or until the timeout expires.  A  nonblocking  call  reads  as
52       many  messages as are available (up to the limit specified by vlen) and
53       returns immediately.
54
55       On return from recvmmsg(), successive elements of msgvec are updated to
56       contain  information  about each received message: msg_len contains the
57       size of the received message; the subfields of msg_hdr are  updated  as
58       described  in  recvmsg(2).   The return value of the call indicates the
59       number of elements of msgvec that have been updated.
60

RETURN VALUE

62       On success, recvmmsg() returns  the  number  of  messages  received  in
63       msgvec;  on  error,  -1  is  returned, and errno is set to indicate the
64       error.
65

ERRORS

67       Errors are as for recvmsg(2).  In addition,  the  following  error  can
68       occur:
69
70       EINVAL timeout is invalid.
71

VERSIONS

73       The recvmmsg() system call was added in Linux 2.6.32.  Support in glibc
74       was added in version 2.12.
75

CONFORMING TO

77       recvmmsg() is Linux-specific.
78

SEE ALSO

80       clock_gettime(2),  recvmsg(2),  sendmmsg(2),   sendmsg(2),   socket(2),
81       socket(7)
82
83
84
85Linux                             2011-09-09                       RECVMMSG(2)
Impressum