- 论坛徽章:
- 0
|
nweb
http://www.ibm.com/developerworks/systems/library/es-nweb.html
nweb: a tiny, safe Web server (static pages only)
Level: Introductory
Nigel Griffiths (nag@uk.ibm.com), pSeries Advanced Technical Support, London, UK, IBM
10 Jun 2004
Updated 25 Sep 2006
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.
Introduction
Have you ever wanted to run a tiny, safe Web server without worrying about using a fully blown Web server that could cause security issues? 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?
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. |
|