Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Re: Http in C? (http://www.velocityreviews.com/forums/t962223-re-http-in-c.html)

Malcolm McLean 06-27-2013 07:40 PM

Re: Http in C?
 
On Thursday, June 27, 2013 7:17:08 PM UTC+1, Bertram wrote:
>
> Do you know if is possible in C, open HTTP connection through a URL,
> download a page in ASCII text or a foto.jpeg
>

Yes, it's rather a hassle because the libraries are non-standard and a bit
difficult to use. But it's certainly achievable.

glen herrmannsfeldt 06-27-2013 10:11 PM

Re: Http in C?
 
Malcolm McLean <malcolm.mclean5@btinternet.com> wrote:
> On Thursday, June 27, 2013 7:17:08 PM UTC+1, Bertram wrote:


>> Do you know if is possible in C, open HTTP connection through a URL,
>> download a page in ASCII text or a foto.jpeg


> Yes, it's rather a hassle because the libraries are non-standard and a bit
> difficult to use. But it's certainly achievable.


Well, there are wget and curl, which might have been written in C.

Easier to run one of them than to write one, though.

-- glen

JohnF 06-28-2013 10:10 AM

Re: Http in C?
 
glen herrmannsfeldt <gah@ugcs.caltech.edu> wrote:
>> Bertram wrote:
>>> Do you know if is possible in C, open HTTP connection through a URL,
>>> download a page in ASCII text or a foto.jpeg

>
> Well, there are wget and curl, which might have been written in C.
> Easier to run one of them than to write one, though. glen


Exactly... very easy to just run. I do this sort of thing all
the time: just FILE *wget = popen("wget -q -O - http://etc","r");
where the "-O -" part makes wget send its output to stdout,
and then you can just fgets(,,wget) until NULL in the usual way,
and then just pclose(wget). The binary jpg stuff might
preferably use fgetc or some other mechanism (I haven't needed
to do that), but I'm sure you get the idea.
Of course, this isn't really "doing it in C", per se,
but I've never heard anybody ask this question for purist purposes.
Rather, it's always been somebody wanted to download something
into their C program for further processing of some sort. And this
gets that job done real well (for me, anyway).
--
John Forkosh ( mailto: j@f.com where j=john and f=forkosh )


All times are GMT. The time now is 08:44 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.