UDP Receive Problem

G

Guest

I am writing a client to request game server information. All of the servers
use UDP to accept commands and send responses. Most of the servers are fine,
but every once in a while a server sends back more than 2k (2048 bytes) of
data and it gets truncated. No matter how large I set the receive buffer, I
only get 2k of data.

Here is what I have tried so far:
- Set the receive buffer to 4096 using Socket.SetSocketOption
- Continue to append received data to a buffer while Socket.Available > 0.
After the first iteration, the available property is zero.
- I have tried both Receive and ReceiveFrom methods. No change.
- Tried asynchronous BeginReceive and EndReceive. I try to invoke begin
receive from EndReceive if the end of data value does not exist, but the
second receive just times out and I'm stuck with the partial data.

Does anyone have any ideas on how I can get more than 2K?
 
©

©tefan ©imek

Pivot said:
I am writing a client to request game server information. All of the
servers
use UDP to accept commands and send responses. Most of the servers are
fine,
but every once in a while a server sends back more than 2k (2048 bytes) of
data and it gets truncated. No matter how large I set the receive buffer,
I
only get 2k of data.

Here is what I have tried so far:
- Set the receive buffer to 4096 using Socket.SetSocketOption
- Continue to append received data to a buffer while Socket.Available > 0.
After the first iteration, the available property is zero.
- I have tried both Receive and ReceiveFrom methods. No change.
- Tried asynchronous BeginReceive and EndReceive. I try to invoke begin
receive from EndReceive if the end of data value does not exist, but the
second receive just times out and I'm stuck with the partial data.

Does anyone have any ideas on how I can get more than 2K?

As far as I know, UDP packet length is limited by the transport layer frame
size. For ethernet, this yields to those 2KB you mention, but for other
networks it might be even less. I guess there is a guaranteed lower bound,
but I don't know for sure.

I guess you will have to either implement your own protocol for packet
merging, or simply make sure you keep the packet size smaller.

HTH, Stefan
 
G

Guest

I'll have to go with the custom packet merging routine. I have no control
over the packet size from these servers.
 

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