![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Oct 2004
Posts: 2
Rep Power: 0
![]() |
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! |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Oct 2004
Location: Canada
Posts: 82
Rep Power: 5
![]() |
Here is some sample code Apache.
|
|
|
|
|
|
#3 |
|
Programmer
Join Date: Oct 2004
Posts: 67
Rep Power: 5
![]() |
FDL.
![]()
__________________
coffee is my heroin. |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0
![]() |
Easy, ten minute job. :blink: :blink: :wacko: :wacko: :unsure:
__________________
Don't wound what you can't kill |
|
|
|
|
|
#5 |
|
Expert Programmer
|
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 |
|
|
|
|
|
#6 |
|
Programming Guru
![]() |
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 |
|
|
|
|
|
#7 |
|
Newbie
Join Date: Nov 2004
Posts: 6
Rep Power: 0
![]() |
if you are a Linux user ;
use www.google.com/linux for searching socket programming and network programming. |
|
|
|
|
|
#8 |
|
Expert Programmer
|
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 |
|
|
|
|
|
#9 | |
|
Newbie
Join Date: Nov 2004
Posts: 24
Rep Power: 0
![]() |
Quote:
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 ![]() |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|