开发者

C#: Socket.ReceiveAsync and partial receives

When using asynchronous sockets, specifically, Socket.ReceiveAsync, is it possible to do a 'partial' receive? For example, I'd like to specify that I expect 1024 bytes on the SocketAsyncEventArgs object开发者_如何学JAVA, but that I want to allow only receiving part of it; for instance, 512 bytes. So instead of waiting for all 1024 bytes to be available, I'd like it to call back with those 512 bytes.

Is this at all possible with asynchronous sockets? Or do I need to resort to non-blocking synchronous mode?

Thanks in advance.


Turns out, what I described in the question is exactly how it works; if one specifies 1024 bytes, the received bytes can be anything <= 1024 bytes.


Just specify how much you need. The rest will still be these next time, unless you're talking about UDP ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜