Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.development.apps > #576
| From | Rainer Weikusat <rweikusat@mssgmbh.com> |
|---|---|
| Newsgroups | comp.os.linux.development.apps |
| Subject | Re: Program hanging on recv() |
| Date | 2013-02-04 19:43 +0000 |
| Message-ID | <87bobzj25k.fsf@sapphire.mobileactivedefense.com> (permalink) |
| References | <kem9lq$ir1$1@dont-email.me> <871ucxoz78.fsf@araminta.anjou.terraraq.org.uk> <kemmvd$nd5$3@dont-email.me> |
Ramon <ramif_47.invalid@yahoo.co.uk> writes:
> 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)
[...]
> *Question*: Is it possible to know the size of the page to download
> beforehand?
If you're only interested in using the TCP connection for a single
request-reply exchange, send a HTTP1.0 request without a Connection:
header or with Connection: close as connection header and call
shutdown(sockfd, SHUT_WR) on you socket after sending the complete
request. The server is then required/ supposed to mark the end of the
reply by closing the connection so you can just read until EOF.
Otherwise, there are (AFAIK) two additional cases to deal with:
- length of the content is provided in form a a Content-Length
header
- so-called 'chunked transfer coding' (reply is send in chunks
each of which is preceded by a chunk length)
Back to comp.os.linux.development.apps | Previous | Next — Previous in thread | Find similar
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