You can use writev
to send a coalesced set of buffers to a single end point if you use connect
to specify the end point beforehand. From the (OSX) manpage for connect(2)
:
datagram sockets may use connect() multiple times to change their association
You cannot use writev
to send each buffer to a different endpoint.
A potential downside of using connect / writev
instead of sendto
*n is that it is yet another system call per writev
.
If the set of recipients is limited (and known in advance) it may be preferable to use a separate socket
per recipient and just connect
each socket once.