Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 21st, 2004, 9:36 PM   #1
searcher
Newbie
 
Join Date: Oct 2004
Posts: 2
Rep Power: 0 searcher is on a distinguished road
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!
searcher is offline   Reply With Quote
Old Oct 21st, 2004, 9:58 PM   #2
Daggerhex_Flynn
Programmer
 
Join Date: Oct 2004
Location: Canada
Posts: 82
Rep Power: 5 Daggerhex_Flynn is on a distinguished road
Here is some sample code Apache.
Daggerhex_Flynn is offline   Reply With Quote
Old Oct 22nd, 2004, 5:54 AM   #3
mici
Programmer
 
Join Date: Oct 2004
Posts: 67
Rep Power: 5 mici is on a distinguished road
FDL.
__________________
coffee is my heroin.
mici is offline   Reply With Quote
Old Oct 22nd, 2004, 8:39 AM   #4
Ade
Hobbyist Programmer
 
Ade's Avatar
 
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0 Ade is an unknown quantity at this point
Easy, ten minute job. :blink: :blink: :wacko: :wacko: :unsure:
__________________
Don't wound what you can't kill
Ade is offline   Reply With Quote
Old Oct 23rd, 2004, 10:38 PM   #5
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
There are many open a closed source projects to help you with this problem, and you should probably look into socket and server/client libraries and frameworks since the system that will work best for you depends really on what it is you want to do.

If you are looking at gaming, you will want to consider DirectPlay possibly.

You can also write a socket library from scratch.. if you are new to coding (which I suspect is the case since you had to ask this question, though I could be wrong) I would recommend against this... leave writing your own socket code until you are willing to put a few months to playing around with it. Socket code is NOT easy by far! And socket code requires a high level of exception and error handling, and there are a lot of states I find socket code can enter.

If you a new to coding, you will likely not finish a proper socket library within a reasonable amount of time. And if you absolutely insist on it... pick up a book on the subject or visit www.gamedev.net (there are plenty of intermediate tutorials on working with socket code there).

Good luck.

PS: A good place to look for open source libraries is sourceforge, I know for fact that there are MANY open source solutions for this.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Oct 25th, 2004, 10:05 AM   #6
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
socket stuff (gets instant headache)
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Old Nov 3rd, 2004, 9:37 AM   #7
101
Newbie
 
Join Date: Nov 2004
Posts: 6
Rep Power: 0 101 is on a distinguished road
if you are a Linux user ;
use www.google.com/linux for searching socket programming and network programming.
101 is offline   Reply With Quote
Old Nov 4th, 2004, 12:41 AM   #8
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Actually thanks to BSD style sockets, the code the would work in linux generally also works on every Unice like machine, DOS and Windows. The only two WSA socket calls I make when using sockets in Windows is WSAStarup() and WSAShutdown() which are absolutely required to intialize and clean up the socket subsystem.

So really that article will give you a great start with Sockets coding in windows two, as long as you mind your type safety, and can figure out who to link the socket libraries in both operating environments.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Nov 5th, 2004, 8:22 AM   #9
phrosys
Newbie
 
Join Date: Nov 2004
Posts: 24
Rep Power: 0 phrosys is on a distinguished road
Quote:
Originally posted by kurifu@Nov 4 2004, 05:41 AM
Actually thanks to BSD style sockets, the code the would work in linux generally also works on every Unice like machine, DOS and Windows. The only two WSA socket calls I make when using sockets in Windows is WSAStarup() and WSAShutdown() which are absolutely required to intialize and clean up the socket subsystem.

So really that article will give you a great start with Sockets coding in windows two, as long as you mind your type safety, and can figure out who to link the socket libraries in both operating environments.
using winsock is the fastest way to write a webserver in C (from the windows enviroment) ; sockets allow you to setup , send , recieve , destroy data/connections, they do/can NOT have anything to do with http or diagrany other protocols in the application layer (refer to the Protocol Stack).

so, i would suggest you read rfc 2616 which clearly defines the http protocol before you begin coding your server.

to have multi-user requests serviced at the same time you use threads (any maybe forks?), so whenever a new user connects you launch a new thread to service that request, this works because the way sockets operate is: users connect to a welcome socket (@ port 80 for http), subsequent communication is through another port (randomly selected)...this means that each new request has a different port, which can be serviced independent of any other requests.

sockets can be made quite portable, threads not so
phrosys is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC