Pergunta

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

Foi útil?

Solução

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.

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top