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...
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins

- My 10 UNIX Command Line Mistakes
- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
Facebook it - Tweet it - Print it -
We're here to help you make the most of sysadmin work. So, subscribe!

{ 22 comments… read them below or add one }
thanks for the tip!
it helped much
i need the C code for HTTP server..Please help me.
I am a student learning how to write a web server, please help me with your source code.
thanks,
iam working a project which will send and receive data from webserver. Your webserver application is suitable for me to develop tmy projet very fast. Can you please forward the source code of the webserver using HTTP to my mail id as follows: galiharish@yahoo.com
want advanced code in C web server
thanks a lot..
how to Write a simple web server in C. This web server only has to respond to GET requests. A web server that serves the same content irrespective of the URL in the GET request is worth 80% of the marks. For further 20% of the marks your server must serve contents based on the file names in the URLs in GET requests.please help me with your source code.
I want to know how to build program for web-server in c
so that client send req for file to server and server gie rpl accordingly
could plz help me to geta web server code in cpp
Hi….
I am planning to do a project in web server. I want a reference source code..Can you send to my mail id : mahenece@gmail.com
Mahendran
plz help me i’m student. i need simple web server using socket source code. how to write mod_php5 source code. my e-mail oyundari_0502@yahoo.com
I am new to network programming. Please send me the source code of your program.
heya! i have just started with network programming. if u can plzz help me by sending ur source code.
i am currently struggling with programming a webserver, would you please to send me the source code, thanks a lot
Hiya im trying to program an embedded web sever, but im finding the coding hard, can u please send me the source code
Hi,
i am getting problems while programming http server. Can you send me your source code. It will be really a great help.
Thans alot.
hı cloud you send your source code please thanks for you attention
hi
thanks for helping,really thanks
can you send for me the C source code?
i need it…thanks a lot…
you have a source code ????
pls help me in developing a web server and tracking the links tracked by an online user . i mean generation of on fly log file
How can we get the source code?
Thank you
http://www.ibm.com/developerworks/systems/library/es-nweb/index.html
i want c codings for web server load balancing…can u send me such coding to my mail?