Receiving multiple datagrams in a single system call
Use recvmmsg to receive multiple datagram packets (example UDP)
int recvmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec *timeout);DESCRIPTION The recvmmsg() system call is an extension of recvmsg(2) that allows the caller to receive multiple messages from a socket using a single system call. ...
http://man7.org/linux/man-pages/man2/recvmmsg.2.html
Use sendmmsg to send...
int sendmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags);DESCRIPTION The sendmmsg() system call is an extension of sendmsg(2) that allows the caller to transmit multiple messages on a socket using a single system call.
There is no such call on Linux. However, depending what you need, there are alternatives:
- Both sendmsg() and recvmsg() can do "scatter/gather" - send/receive a single packet from multiple buffers.
- "pktgen" ( http://www.linuxfoundation.org/collaborate/workgroups/networking/pktgen ) is a kernel module which can transmit millions of packets with just a handful of file writes for the testing purposes.