views:

217

answers:

3

When datagram-based socket (raw socket or UDP) is used with gather-style send, all the data are concatenated to form a single IP packet. Is there a way to send several datagrams using a single call?

A: 

I don't think so ... How would you expect the IP stack to infer where you intend the packet datagram to be?

unwind
Each iovec a separate datagram?
A: 

What you are asking is a bit funny since gather-style send() as the name says gathers data from multiple places in memory and puts it together into one buffer which it then sends.

So you have multiple parts of data you want to send multiple datagrams. Why don't you send them with separate calls to send?

You can actually call connect() on a datagram socket to specify a default target so you can can send() or write() without specifying the destination address each time.

codymanix
A: 

The call you are looking for is sendmmsg() however it is not yet implemented or even up for much discussion. You can see it's receive side twin recvmmsg() in the latest 2.6.3 Linux kernel.

Steve-o