Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

For this activity, you will submit two .java files. You will need to run two classes simultaneously for this activity. Make sure you have a

For this activity, you will submit two .java files. You will need to run two classes simultaneously for this activity. Make sure you have a compiler that is capable of this.

Now that youve learned how to connect multiple Clients to a single Server, were going to look at how this affects data being sent back and forth.

For this program, youre going to write a single Client class and a Server class just like before. Your Server class should accept two connections one for each Client (youll run your Client class twice like before as well). This time, after both Clients connect, your Server will send them both an ID like last time. Once a Client has gotten an ID, the Client should ask the user input for a name to go with their ID. The Client will enter their name and send it back to the Server. The Server will connect both names and print out the ID-name combinations like this:

ID1: Name1 ID2: Name2

Finally, the Server will finish and disconnect. The Clients should also disconnect. Both sides should close everything and finish running.

Note: Both clients must connect to the Server before the IDs are sent. They must both be connected to the Server simultaneously.

To summarize, your program should do the following:

Create a Server class with two Sockets and one ServerSocket.

Create a Client class. This class will connect to the Server once.

Have the Server accept two Client connections.

Send unique IDs to each Client.

Have each Client get a String name (or username) from their user.

The Client sends their name (or username) to the Server.

The Server reads the names from both Clients and displays them with their IDs.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students explore these related Databases questions