sendmmsg(2) System Calls Manual sendmmsg(2) sendmmsg - C (libc, -lc) #define _GNU_SOURCE /* feature_test_macros(7) */ #include int sendmmsg(int sockfd, struct mmsghdr msgvec[.n], unsigned int n, int flags); sendmmsg() sendmsg(2), , ( ). sockfd . The msgvec argument is a pointer to an array of mmsghdr structures. The size of this array is specified in n. mmsghdr : struct mmsghdr { struct msghdr msg_hdr; /* */ unsigned int msg_len; /* - */ }; msg_hdr msghdr, sendmsg(2). msg_len , msg_hdr (. ., , sendmsg(2)). flags OR . , sendmsg(2). A blocking sendmmsg() call blocks until n messages have been sent. A nonblocking call sends as many messages as possible (up to the limit specified by n) and returns immediately. sendmmsg(), msg_len msgvec , msg_hdr. msgvec, . On success, sendmmsg() returns the number of messages sent from msgvec; if this is less than n, the caller can retry with a further sendmmsg() call to send the remaining messages. -1, errno . sendmsg(2). , . . Linux. Linux 3.0, glibc 2.14. The value specified in n is capped to UIO_MAXIOV (1024). , . . , , , . sendmmsg() onetwo three UDP . . #define _GNU_SOURCE #include #include #include #include #include #include #include int main(void) { int retval; int sockfd; struct iovec msg1[2], msg2; struct mmsghdr msg[2]; struct sockaddr_in addr; sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd == -1) { perror("socket()"); exit(EXIT_FAILURE); } addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); addr.sin_port = htons(1234); if (connect(sockfd, (struct sockaddr *) &addr, sizeof(addr)) == -1) { perror("connect()"); exit(EXIT_FAILURE); } memset(msg1, 0, sizeof(msg1)); msg1[0].iov_base = "one"; msg1[0].iov_len = 3; msg1[1].iov_base = "two"; msg1[1].iov_len = 3; memset(&msg2, 0, sizeof(msg2)); msg2.iov_base = "three"; msg2.iov_len = 5; memset(msg, 0, sizeof(msg)); msg[0].msg_hdr.msg_iov = msg1; msg[0].msg_hdr.msg_iovlen = 2; msg[1].msg_hdr.msg_iov = &msg2; msg[1].msg_hdr.msg_iovlen = 1; retval = sendmmsg(sockfd, msg, 2, 0); if (retval == -1) perror("sendmmsg()"); else printf("%d messages sent\n", retval); exit(0); } recvmmsg(2), sendmsg(2), socket(2), socket(7) () Alexander Golubev , Azamat Hackimov , Hotellook, Nikita , Spiros Georgaras , Vladislav , Yuri Kozlov , Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.15 17 2025 . sendmmsg(2)