how would I go about creating a Socket receiveAll method?

Adam D. Ruppe destructionator at gmail.com
Tue Dec 12 22:11:37 UTC 2017


On Tuesday, 12 December 2017 at 21:52:57 UTC, Ali Çehreli wrote:
> The same buffer is used for all segments and socket.receive 
> should be inside while.

The buffer is copied by the ~= operator, but indeed you're right 
that I forgot to receive again inside the loop! That would just 
spin until it ran out of memory lol.

But I did put receive outside the loop for a reason: it just 
needs to prime the return value before it gets checked the first 
time. But then, of course, it should receive again at the end of 
the loop to advance to the next chunk.


More information about the Digitalmars-d-learn mailing list