How a Web server actually works ~ with C source code
Do you wonder how to write a program that accepts incoming messages with a network socket? Have you ever just wanted your own Web server to experiment and learn with?
Have you ever wondered how a Web server actually works? Experiment with nweb -- a simple Web server with only 200 lines of C source code. In this article, Nigel Griffiths provides a copy of this Web server and includes the source code as well. You can see exactly what it can and can't do.
Well, look no further -- nweb is what you need. This is a simple Web server that has only 200 lines of C source code. It runs as a regular user and can't run any server-side scripts or programs, so it can't open up any special privileges or security holes.
This article covers:
- What the nweb server program offers
- Summary of C functions features in the program
- Pseudo code to aid understanding of the flow of the code
- Network socket system calls used and other system calls
- How the client side operates
- C source code
nweb only transmits the following types of files to the browser :
- Static Web pages with extensions .html or .htm
- Graphical images such as .gif, .png, .jgp, or .jpeg
- Compressed binary files and archives such as .zip, .gz, and .tar
- If your favorite static file type is not in this list, you can simply add it in the source code and recompile to allow it.
Read more at IBM developerworks...
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in other helpful articles:
- Security breach: Facebook index.php source code leaked
- Red Hat RPM Dependency problem
- A List of 400+ Open Source Software
- FreeBSD >Sending a Message to All Users on a Remote UNIX/Linux/FreeBSD System
- Linux Cutting the tcp/ip network connection with cutter command
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: c functions, c source code, graphical images, gz, ibm developerworks, incoming messages, jgp, network socket, nweb, png, privileges, pseudo code, security holes, server program, server side scripts, simple web server, socket system, static file, static web, web pages


Recent Comments
Today ~ 12 Comments
Today ~ 6 Comments
Today ~ 21 Comments
Today ~ 1 Comment
Today ~ 1 Comment