Question: How to use Java to write the following: Remember that your program is probably not going to be able to listen on port 80. To
How to use Java to write the following:

Remember that your program is probably not going to be able to listen on port 80. To tell a web brower to connect to a web server on an alternate port, append a ":" and the port number to the URL. For example, you could always try testing the server on your own computer, with the client using the address: http://127.0.0.1:9999, after you type in this (http://127.0.0.1:9999), the broswer window should return the public IP address and current of the host.
Write a program which specifies at run time . a port number on which to listen for incoming connections . the name of a log file The program listens on the TCP port specified. When a connection is made, the server sends back an HTTP 200 response and HTML text, which when shown in a browser, will display . "Your IP address is:" followed by the IP address of the machine that has connected. The IP address of the client may be obtained by using the getInetAddress method in the socket class . It should then print the current date and time. In order to obtain the current date and time, you can use the java Date class The program then writes to the log file: the time, IP address of the client, and all of the HTTP headers sent by the client For example, when I try the program on my own computer, I see in the browser: Your IP address is 129.32.95.12 The current time is: Mon Oct 17 15:17:22 EDT 2016 and then to the file, the program writes something like: Mon Oct 17 15:17:22 EDT 2016 IP: 129.32.95.12 GET/HTTP/1.1 Host: localhost: 9999 Connection: keep-alive User-Agent: Mozilla/5.0 (X11; Linux x86_64) ApplewebKit/535.1 (KHTML, like Accept: text/html,application/xhtml+xml,application/xml;q 0.9,*/*;q-0.8 Accept-Encoding: gzip,deflate, sdch Accept-Language: en-US,enq-0.8 Accept-Charset: ISO-8859-1,utf-8;q-9.7, * ; q=0.3 Gecko) Chrome/14.0.835.186 Safari/535.1 You should be able to test your program with a web browser to see that it's doing what it should
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
