comp.lang.ada
 help / color / mirror / Atom feed
From: "John B. Matthews" <nospam@nospam.invalid>
Subject: Re: GNAT.Sockets. Blocking?
Date: Tue, 23 Jun 2009 20:14:47 -0400
Date: 2009-06-23T20:14:47-04:00	[thread overview]
Message-ID: <nospam-FC0476.20144723062009@news.aioe.org> (raw)
In-Reply-To: 158756da-21b7-4e2d-b288-7ba030f1f35c@25g2000yqb.googlegroups.com

In article 
<158756da-21b7-4e2d-b288-7ba030f1f35c@25g2000yqb.googlegroups.com>,
 "Jacob M. H. Smith" <jacob.m.h.smith@googlemail.com> wrote:

> I'm kind of new to socket programming and I need some help here. I 
> wrote a simple little program that just fetches Google's index page. 
> The posted code works, but only because I used a "Connection: close" 
> header in the HTTP request. How would set up my code responsible for 
> reading the data from the stream so that I can read the page while 
> keeping the connection open? If I remove the header the program seems 
> to stop when calling the Ada.Streams.Read function if there is less 
> than BUFFER_SIZE data in the streams buffer. Can't I just read as 
> much as is available?
[...]

The Google page specifies "Transfer-Encoding: chunked", which must be 
"terminated by closing the connection." To get the whole page, I think  
you'd need to handle the chunk-size:

<http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6>

Your code gets www.example.com correctly, without an explicit 
"Connection: close":

<http://www.rfc-editor.org/rfc/rfc2606.txt>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



  reply	other threads:[~2009-06-24  0:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-23 21:06 GNAT.Sockets. Blocking? Jacob M. H. Smith
2009-06-24  0:14 ` John B. Matthews [this message]
2009-06-24  4:55   ` Jacob M. H. Smith
2009-06-24 14:36     ` John B. Matthews
2009-06-24  7:47 ` Dmitry A. Kazakov
2009-06-24 13:32 ` anon
2009-06-24 14:03 ` anon
2009-06-24 15:14 ` Pascal Obry
2009-06-24 18:44 ` Simple solution was " anon
2009-06-24 18:47 ` Per Sandberg
2009-06-24 19:51   ` Pascal Obry
2009-06-24 22:12   ` Jeffrey R. Carter
2009-06-25 17:30     ` Jacob M. H. Smith
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox