On Thu Jan 10 04:43:32 2013, moritz wrote:
> On Sat Jan 05 01:10:17 2013, FROGGS.de wrote:
> > So if somebody doesnt know the chunk size, (s)he will be unable to use
> > read() at all. _If_ you know the chunk size you can say:
> > 
> >   last if $data < $chunk-size
> 
> If one doesn't know how much data to expect, one simply uses .recv.
> Currently there's no version of .recv that returns a Buf (only Str), but
> providing one is the proper fix.

By now, things have been sorted out so that:

* read will do repeated socket reads to get sufficient data to meet what was 
requested, unless the connection is closed in which case it can return less; 
it'll never return more

* recv will only ever do one actual recv on the socket, so if one read does not 
produce enough data, you'll just get a short result; the optional argument 
serves as an upper limit

And these days, recv has a :bin parameter.

Tests codifying this behavior in S32-io/socket-recv-vs-read.t.

Reply via email to