CSC3320 Assignment 6 25 points due 4/24/02 Dr. Harrison Spring 2002

This assignment builds on the last one (assignment 5). You are going to write a minimal web server. When complete it should be emailed to the GTA in ONE email (use either attachments (preferred -use pine) or a tar file). His account is slp40@yamacraw.cs.gsu.edu. Printed copies of the files should also be handed to me.



  1. Write a program that creates a socket, binds it to port 8000 + the number in your id (i.e. if you are slp10 then bind to 8010), puts the socket in passive mode and waits in an accept call. The program should use chroot and chdir to ensure that it cannot be used to send data that are not in its current working directory. The program should continue to run after a connection, and should close the sockets it uses. (although you may want to first develop the program in a version that closes the sockets and exits)





  1. The program should respond to the input GET <a_file_name> HTTP\<a_number> followed by an empty line with the contents of the file specified or a message "404 file not found -" appended by the file name. This is a simplification of the correct response which would be:

    HTTP:/<the_number> 200 OK

    Date: <the date>

    Server: <a name>

    Last-Modified: <another date>

    Content-Length: <the size of the file in bytes>

    Content-Type: text/html

    <a blank line>

    The data


I will post a program that contains a method that does this, but it would be much better for you if you used your own.