C# Begin/EndReceive – how do I read large data?

No – call BeginReceive again from the callback handler, until EndReceive returns 0. Basically, you should keep on receiving asynchronously, assuming you want the fullest benefit of asynchronous IO.

If you look at the MSDN page for Socket.BeginReceive you’ll see an example of this. (Admittedly it’s not as easy to follow as it might be.)

Leave a Comment