CS33300 - Assignment 1
Handed out: Tuesday, March 30, 2004
Due: Tuesday, April 6, 2004. 11:59 p.m.
Web Server
Your task is to write a simple web server capable of delivering both
files and running CGI programs. Your web server must be compiled into a file
called 'webserve' and run as follows:
% webserve 12345
Yourname web server.
Listening on port 12345
The argument to the web server is the TCP port number on which
connections are to be received. This can be any number in the range
1024-65535.
Once the web server is running, users should be able to connect to it using any
browser. Simply enter a URL such as:
http://somemachine.cs.uchicago.edu:12345/index.html
Requirements
- The server must be written in C.
- The server is only allowed to deliver files from the same directory in which it is
started. Accessing subdirectories is okay as long as the subdirectories are below
the starting directory.
- If a file has UNIX execute permissions, your web server should treat it as a CGI program
and run it.
- Your server should minimally recognize the following file types---to be determined solely
by file suffix (.html, .jpg, .gif, .png, .txt). All other files should be sent back as raw
data of unknown type.
- Your server only needs to support the HTTP/1.0 protocol and only needs to implement
the HTTP "GET" operation.
Implementation Hints
- Read the "Unix Network Programming" book and learn about programming with sockets.
- Web servers operate using something known as the HTTP protocol. Find out details
of the protocol by searching on the web or consulting a book.
- Search the web for details of how CGI programs work.
Testing
To test your web-server, we will run it from the following directory:
/stage/classes/current/33000-1/test/assign1
We will then connect your web server and attempt to load a file called "index.html."
Handin
Your assignment should consist of three files:
Makefile - Makefile for the project
webserver.c - Source code for the server
README - README file with your name and details
You are free to implement the web server in any manner that you see fit.
To hand in your assignment:
- Put all of your files in a directory called 'assign1'
- Make a tar-ball
% tar -cf yourname_assign1.tar assign1
- Verify contents
% tar -tf yourname_assign1.tar
assign1/Makefile
assign1/README
assign1/webserver.c
- Hand it in
% cp yourname_assign1.tar /stage/classes/current/33300-1/handin/assign1