(Phobos - SocketStream) Am I doing something wrong or is this a bug?

Zane zane.sims at gmail.com
Tue Nov 3 15:26:19 PST 2009


BCS Wrote:

> Hello Zane,
> 
> > While trying to learn sockets in Phobos, I ran into a problem.  I was
> > trying to download the google logo via an HTTP GET.  when I do a
> > socketStream.read, the returned "bytes read" value indicates that less
> > bytes were read in than were available (4097 bytes to be exact).  The
> > google logo is 8558 bytes in size as indicated by the HTTP headers
> > received.  Here is my code:
> > 
> 
> The network connection might not have all the data yet. Try calling it in 
> a loop kind of like your header reading code.
> 
> 

I do not see how this can be the case.  Per the Phobos spec for InputStream, "Read a block of data big enough to fill the given array buffer. "  This sounds to me like it should do just that, fill my array....and not return until done.  readLine needs to be looped because it only reads up to a carriage return / newline combination (and there are multiple lines).  Can anyone confirm that my speculations are correct?  Otherwise, the documentation seems misleading and I will need help with a correct implementation.

Zane



More information about the Digitalmars-d mailing list