Objectives -
The object of this exercise is to write a multi-threaded HTTP server, showing both your understanding of the networking API and also of the programming techniques required to leverage that API effectively.
There are three small exercises which do not count for marks directly, but which are intended to help you prepare for the main element of the assignment. You do not have to do these exercises, but you are assumed to have a full understanding of their content.
Environment and tooling
These exercises should all be written in (preferably) C or (if you cannot program in C) Java. They should all run, unmodified, on the school's Linux teaching systems. If you develop on another platform, you should confirm that your code builds and runs on the school Linux machines.
Your program should access the socket interface directly. For C this is straightforward; for Java, you should use java.net.Socket, not one of the more abstract networking classes.
If you work in Java, your program should run from the command line using the java command; it is not sufficient to submit an Eclipse project and expect the marker to figure out how to run it. You should include a Makefile whose all target uses the javac command to compile your code.
If you work in C, there should be a Makefile whose all target builds all the required programs.
Preparatory Exercises
Write a program which accepts a single incoming connection, using listen() and accept(), and displays all received data on the screen. You can test this program using telnet or netcat. Once you have completed this task, swap your code with a colleague and have them test it; they should give you a one or two paragraph report on its function and the code itself.
Extend this program so that it will accept multiple connections, in parallel, and display all received traffic on the screen. This will involve the use of pthreads, for C, or you can if you wish use fork(). For Java, you will need to use implements Runnable, extends Thread or some other threading mechanism. Again, have a colleague (ideally a different one) evaluate your code.
Extend this program so that instead of just displaying what is sent to it, it instead parses an HTTP request and request header (you will need to read RFC 2616 for the full details) and displays the broken-out fields on the screen. You should be able to test this with wget or curl: the client will show errors when your program closes the connection without returning any results, but your program should produce correct output on the screen. Again, have a colleague (and, again, a different one) evaluate your code.
If requested I can set Canvas up to handle this peer feedback, but I would prefer you to actually meet and talk to people!
Main Exercise
You should write a web server which interacts correctly with a web browser, serving content from either the file system or a small database. It should provide an index page when visited with a null URI, and then correctly handle subsequent requests arises from clicking on the items in the index.
The program should be correctly multi-threaded, and handle multiple clients connecting rapidly in parallel.
Attachment:- Assignment File.rar