Will The OS send more then one message in a datagram, if it has the room, for efficiency.

  • Thread starter Thread starter DaTurk
  • Start date Start date
D

DaTurk

I know in TCP if you send a message down the wire, the OS may lump
subsequent messages into a buffer before sending it across the wire,
for efficiency. But, will the OS do the same thing with UDP?

I'm just concerned that I may be getting multiple messages in a single
datagram. I'm using a connectionless multicast paradigm where there
are multiple receivers listening asynchronously, and a single sender
sending synchronously.
 
DaTurk said:
I know in TCP if you send a message down the wire, the OS may lump
subsequent messages into a buffer before sending it across the wire,
for efficiency. But, will the OS do the same thing with UDP?

Have a look at the MSDN help for the Socket.ReceiveFrom method. It
always returns the next available datagram or blocks until something is
available.

You have to take care on the other side.. on TCP you can specify a
buffer that's smaller than the number of bytes available. If you do this
on UDP you'll get a SocketException and lose every datagram that's too
big to fit into your buffer.

hth,
Max
 
DaTurk said:
I know in TCP if you send a message down the wire, the OS may lump
subsequent messages into a buffer before sending it across the wire,
for efficiency. But, will the OS do the same thing with UDP?

No. Datagram sockets preserve message boundaries. Of course if the sending
application coalesces multiple payloads into one sendto() call, then Windows
considers that just one message.
 
Back
Top