hii i need the complete answers

Lab 10: A Singlefile HTTP Server with extension to Serve any HTML File

A web server is a server program that waits for incoming requests on the HTTP port and acts on those to send the contents of local files back to the requester. It can be implemented in just a few dozen lines of code. The lab assignment here is part of the code for a web server.


Your Lab 10 assignment is to write a program that opens a server socket on the http port, port 80, and listens for requests from web browsers. When a request comes for a file, it always sends a fixed single file. Test your program by running the server on your machine and passing a specific html file to be always displayed in response to a web browser’s request to this web site. Users will point their browsers to localhost on your machine or its IP address from other machines.


Optional: In the 2nd phase, you would modify your socket server program to handle a GET request for any HTML file available at the root directory of the web server. You may use your localhost as the web server machine or the URL for the server. It is desirable if you could use multithreading by creating a thread to serve each request.



Please study Chapter 9 of your textbook for further information on how to write a web server and its components.