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

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.
 
M

Markus Stoeger

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
 
B

Ben Voigt

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top