Re: Http in C?

Discussion in 'C Programming' started by Malcolm McLean, Jun 27, 2013.

  1. 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.
    Malcolm McLean, Jun 27, 2013
    #1
    1. Advertising

  2. Malcolm McLean <> 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
    glen herrmannsfeldt, Jun 27, 2013
    #2
    1. Advertising

  3. Malcolm McLean

    JohnF Guest

    glen herrmannsfeldt <> 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: where j=john and f=forkosh )
    JohnF, Jun 28, 2013
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jiong Feng
    Replies:
    0
    Views:
    818
    Jiong Feng
    Nov 19, 2003
  2. Paul Glavich [MVP - ASP.NET]
    Replies:
    0
    Views:
    447
    Paul Glavich [MVP - ASP.NET]
    Jun 20, 2004
  3. T. Regan
    Replies:
    3
    Views:
    708
    T. Regan
    Jun 21, 2004
  4. NNTP
    Replies:
    2
    Views:
    982
    =?Utf-8?B?S2V2aW4gVG9kZA==?=
    Mar 18, 2005
  5. larkpics
    Replies:
    9
    Views:
    9,002
    Patrick.O.Ige
    Oct 22, 2005
Loading...

Share This Page