How To Use C To Write A Web Server?

Discussion in 'C Programming' started by searcher1234, Oct 22, 2004.

  1. searcher1234

    searcher1234 Guest

    Hi,

    I just start learning network programming. How can I write a web server
    with
    "C" so that it can connect to web browser and read the request, accept the
    request,
    open requested html page, send it back to the web browser for user
    viewing.

    One more is how can i allow multi-users send request to the web server?

    if possible, Could you post sample code?


    Thank you!
     
    searcher1234, Oct 22, 2004
    #1
    1. Advertising

  2. searcher1234

    Artie Gold Guest

    searcher1234 wrote:
    > Hi,
    >
    > I just start learning network programming. How can I write a web server
    > with
    > "C" so that it can connect to web browser and read the request, accept the
    > request,
    > open requested html page, send it back to the web browser for user
    > viewing.
    >
    > One more is how can i allow multi-users send request to the web server?
    >
    > if possible, Could you post sample code?
    >


    You can do it by using platform specific extensions.

    Please post to a newsgroup specific to your particular platform.

    HTH,
    --ag

    --
    Artie Gold -- Austin, Texas

    "If you don't think it matters, you're not paying attention."
     
    Artie Gold, Oct 22, 2004
    #2
    1. Advertising

  3. >I just start learning network programming. How can I write a web server

    Network programming is outside the scope of standard C.
    You may want comp.unix.programmer .

    >with
    >"C" so that it can connect to web browser and read the request, accept the
    >request,
    >open requested html page, send it back to the web browser for user
    >viewing.
    >
    >One more is how can i allow multi-users send request to the web server?


    Multiple processes and/or threads are also outside the scope
    of standard C.

    >if possible, Could you post sample code?


    Apache is an open-source web server. http://www.apache.org/

    Gordon L. Burditt
     
    Gordon Burditt, Oct 22, 2004
    #3
  4. joerg schleede, Oct 22, 2004
    #4
  5. searcher1234

    CBFalconer Guest

    searcher1234 wrote:
    >
    > I just start learning network programming. How can I write a web
    > server with "C" so that it can connect to web browser and read the
    > request, accept the request, open requested html page, send it
    > back to the web browser for user viewing.
    >
    > One more is how can i allow multi-users send request to the web
    > server?
    >
    > if possible, Could you post sample code?


    Sure:

    int main(int argc, char **argv)
    {
    abrowser brow;
    arequest request;

    if (validateargs(argc, argv) {
    brow = openbrowser(argv[1]);
    while (request = getrequest(brow)) {
    view(open_page(request));
    }
    }
    return 0;
    }

    should do it, once you flesh it out with a few #includes, data
    definitions, functions, etc.

    --
    "I support the Red Sox and any team that beats the Yankees"
    "Any baby snookums can be a Yankee fan, it takes real moral
    fiber to be a Red Sox fan" - "I listened to Toronto come back
    from 3:0 in '42, I watched Boston come back from 3:0 in '04"
     
    CBFalconer, Oct 22, 2004
    #5
  6. In article <>, Artie Gold <> writes:
    > searcher1234 wrote:
    > > I just start learning network programming. How can I write a web server
    > > with
    > > "C" so that it can connect to web browser and read the request, accept the
    > > request,
    > > open requested html page, send it back to the web browser for user
    > > viewing.

    >
    > You can do it by using platform specific extensions.


    Not even then, since web browsers, as a rule, do not accept inbound
    connections. Now, if the OP wanted to write a server that accepted
    a connection from a browser, that would merely be off-topic.

    > Please post to a newsgroup specific to your particular platform.


    I'd recommend comp.protocols.tcp-ip, where the relevant protocols and
    some of the relevant APIs and techniques are discussed, and
    comp.infosystems.www.servers.misc, which covers this topic in general,
    but my feeling is the OP is nowhere near ready to tackle building an
    HTTP server.

    Writing an HTTP server from scratch is a non-trivial task. I suggest
    the OP consult the FAQs for the groups above to learn where to go to
    learn what's involved.

    --
    Michael Wojcik

    Thanks for your prompt reply and thanks for your invitatin to your
    paradise. Based on Buddihism transmigration, I realize you, European,
    might be a philanthropist in previous life!
    -- supplied by Stacy Vickers
     
    Michael Wojcik, Oct 22, 2004
    #6
    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. -
    Replies:
    2
    Views:
    436
    Alan Krueger
    Jul 29, 2005
  2. =?Utf-8?B?QWJlbCBDaGFu?=
    Replies:
    6
    Views:
    9,493
    Rahul
    May 3, 2006
  3. Lit
    Replies:
    1
    Views:
    613
    Jesse Houwing
    Aug 3, 2007
  4. Jake
    Replies:
    1
    Views:
    351
    Paul Glavich [MVP - ASP.NET]
    May 5, 2004
  5. sahm
    Replies:
    4
    Views:
    706
Loading...

Share This Page