How To Use C To Write A Web Server?

S

searcher1234

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!
 
A

Artie Gold

searcher1234 said:
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
 
G

Gordon Burditt

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
 
C

CBFalconer

searcher1234 said:
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.
 
M

Michael Wojcik

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 (e-mail address removed)

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top