Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.apps > #571

Re: Program hanging on recv()

From Lew Pitcher <lpitcher@teksavvy.com>
Subject Re: Program hanging on recv()
Newsgroups comp.os.linux.development.apps
References <kem9lq$ir1$1@dont-email.me> <871ucxoz78.fsf@araminta.anjou.terraraq.org.uk> <kemmvd$nd5$3@dont-email.me>
Message-ID <2RBPs.121278$EO2.90547@newsfe04.iad> (permalink)
Date 2013-02-03 17:50 -0500

Show all headers | View raw


On Sunday 03 February 2013 17:05, in comp.os.linux.development.apps,
ramif_47.invalid@yahoo.co.uk wrote:

> What I'm actually doing is just downloading an XML page to memory using
> the HTTP protocol. (e.g.
> http://weather.yahooapis.com/forecastrss?w=2502265)
[snip]
> 
> *Question*:  Is it possible to know the size of the page to download
> beforehand?

Yes, and no.

If you first converse with the HTTP server using a HEAD method, you will
get, in the response, a "Content-Length" tag which will tell you how big
the content is. The problem is that this is still a TCP conversation, and
will have the same "response size" issue that you currently have, but for
it's own response. In other words, you will *not* know how big the server's
response to your HEAD request will be beforehand, and will only be able to
detect that you've received it all by encountering the termination of the
conversation.

If you send a GET method instead, you will get both the response headers
(including the "Content-Length" header) /and/ the data contents.

In either case, you *must* interpret the data you receive from the server to
determine how big the response is going to be.

> Or is then any other way how I can solve the recv() hanging 
> issue?

Is there any reason you can't use already existing utilities to fetch the
page /as a file/, and then perform post-processing on that file? If not,
then why not just use wget(1) (or similar) to retrieve the XML into a file,
and then process the file without worrying about the HTTP protocol?

HTH
-- 
Lew Pitcher
"In Skills, We Trust"

Back to comp.os.linux.development.apps | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Program hanging on recv() Ramon <ramif_47.invalid@yahoo.co.uk> - 2013-02-03 19:18 +0100
  Re: Program hanging on recv() Richard Kettlewell <rjk@greenend.org.uk> - 2013-02-03 21:38 +0000
    Re: Program hanging on recv() Ramon <ramif_47.invalid@yahoo.co.uk> - 2013-02-03 23:05 +0100
      Re: Program hanging on recv() Lew Pitcher <lpitcher@teksavvy.com> - 2013-02-03 17:50 -0500
      Re: Program hanging on recv() Richard Kettlewell <rjk@greenend.org.uk> - 2013-02-03 23:16 +0000
      Re: Program hanging on recv() Jasen Betts <jasen@xnet.co.nz> - 2013-02-04 11:10 +0000
        Re: Program hanging on recv() Ramon <ramif_47.invalid@yahoo.co.uk> - 2013-02-04 21:21 +0100
      Re: Program hanging on recv() Rainer Weikusat <rweikusat@mssgmbh.com> - 2013-02-04 19:43 +0000

csiph-web