Starting from:
$10

$4

Computer Networks Lab Excercises #3 Solution

Instructions: This is a demo based assignment that will require you to write codes for the server. You have to show the demo to the TA and submit the codes in a tgz le with name assign3.tgz. The submission date is 01.02.2018.




In this assignment, you will learn the basics of socket programming for TCP connections in Java: how to create a socket, bind it to a speci c address and port, as well as send and receive a HTTP packet. You will also learn some basics of HTTP header format.



You will need to develop a web server that handles one HTTP request at a time. Your web server should run on an instance in the virtual box environment and should accept and parse the HTTP request, get the requested le from the servers le system, create an HTTP response message consisting of the requested le preceded by header lines, and then send the response directly to the client. If the requested le is not present in the server, the server should send an HTTP 404 Not Found message back to the client.




To run the web server, put an HTML le (e.g., HelloWorld.html) in the same instance that the server is in. Run the server program. Determine the IP address of the host instance that is running the server (e.g., 172.16.1.156). From another host instance, open a browser and provide the corresponding URL. For example: http://172.16.1.156:1234/HelloWorld.html HelloWorld.html is the name of the le you placed in the server directory. Note also the use of the port number after the colon. You need to replace this port number with whatever port you have used in the server code. In the above example, we have used the port number 1234. The browser should then display the contents of HelloWorld.html. If you omit ":1234", the browser will assume port 80 and you will get the web page from the server only if your server is listening at port 80. Then try to get a le that is not present at the server. You should get a 404 Not Found message.







You will hand in the complete server code along with the screen shots of your client browser, verifying that you actually receive the contents of the HTML le from the server.




Extend the previous problem to implement a multithreaded web server that can open con-current connections with more than one browsers. there should be a separate con guration le for the web server, that it should read initially to con gure itself. The con guration le should have the following elds:



The maximum number of concurrent requests that the server would support.



The IP addresses that it would lter, i.e. the IP addresses that the web server would block.



The default html le along with its path name, that the webserver would return.

























































1

More products