Connecting Tech Pros Worldwide Forums | Help | Site Map

How To Use C To Write A Web Server?

searcher1234
Guest
 
Posts: n/a
#1: Nov 14 '05
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!



Artie Gold
Guest
 
Posts: n/a
#2: Nov 14 '05

re: How To Use C To Write A Web Server?


searcher1234 wrote:[color=blue]
> 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?
>[/color]

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."
Gordon Burditt
Guest
 
Posts: n/a
#3: Nov 14 '05

re: How To Use C To Write A Web Server?


>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 .
[color=blue]
>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?[/color]

Multiple processes and/or threads are also outside the scope
of standard C.
[color=blue]
>if possible, Could you post sample code?[/color]

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

Gordon L. Burditt
joerg schleede
Guest
 
Posts: n/a
#4: Nov 14 '05

re: How To Use C To Write A Web Server?


try this ?

http://sourceforge.net/projects/nullhttpd/


js
CBFalconer
Guest
 
Posts: n/a
#5: Nov 14 '05

re: How To Use C To Write A Web Server?


searcher1234 wrote:[color=blue]
>
> 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?[/color]

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"


Michael Wojcik
Guest
 
Posts: n/a
#6: Nov 14 '05

re: How To Use C To Write A Web Server?



In article <2tr7o3F22or99U1@uni-berlin.de>, Artie Gold <artiegold@austin.rr.com> writes:[color=blue]
> searcher1234 wrote:[color=green]
> > 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.[/color]
>
> You can do it by using platform specific extensions.[/color]

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.
[color=blue]
> Please post to a newsgroup specific to your particular platform.[/color]

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 michael.wojcik@microfocus.com

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
Closed Thread