Question: Write a simple HTTP client and a separate HTTP server application in Java. As soon as the client connects, the server will send a html

Write a simple HTTP client and a separate HTTP server application in Java. As soon as the client connects, the server will send a html or text file which is between 5 to 10K bytes in size. Close the connection once the file is transmitted.

Make sure the files are named differently on the client and server side.

You must use the Java socket class.

DO NOT implement the server handling multiple requests at the same time (multi-threading).

Implement output messages that show the flow through each method (e.g. Connected to server or Receiving message from server, etc)

Show sample output of the file transfer (both client and server)

1. Create the Java code and compile it.

2. Run it on your own machine with a port number specified in the command line For example, type: java MyServer 25000 ). If a service is already running on the port you choose, you will get a BindException or a similar exception.

3. In another window, use Telnet as the client program by typing a command telnet localhost 25000 . This will test that the Server application is working.

4. Now test using the Java client by typing: java MyClient 25000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!