Question
Use Java to write a program which specifies at run time: - a port number on which to listen for incoming connections. - the name
Use Java to 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 a HTTP 200 repsonse and HTML text, which when shown in a broswer, will display:
Your IP address is: 129.32.95.12
The current time is: Mon Oct 17 15:17:22 EDT 2016
and then write to the file (.txt), the program writes something like blow to the .txt file:
You should be able to test your program with a web broswer to see that's it's doing what it should. 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, running test on your own computer, with the client using the address: http://127.0.0.1:9999
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 Gecko) Chrome/14.0.835.186 Safari/535.1 Accept: text/html,application/xhtml+xml,application/xml:q-0.9,*/q =0.8 Accept-Encoding: gzip, deflate,sdch Accept-Language: en-US, en:q 0.8 Accept-Charset: ISO-8859-1,utf-8:q0.7, *q0.3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started