Question: Java: Create a multi-threaded phone server, where the processing of each incoming request will take place inside a separate thread of execution. Client.java 1. Request
Java: Create a multi-threaded phone server, where the processing of each incoming request will take place inside a separate thread of execution.
Client.java
1. Request a connection with the server
2.Send three types of messages through established connection:
STORE messages containing name and phone number
GET messages containing requests for phone number
REMOVE messages containing requests to remove a number from the list
Server.java
1. Accept requested connections and support multiple connections
2. Maintain an appropriate data structure (a list) that holds data received from a client. The data stored on server is a list of names and phone numbers which is empty at startup. It is not persistent.
3. Process messages received from the client:
If message is STORE with a pair of name and number, server will have to update the list of phone numbers
If the message is GET with a request (a name as a content), the server has to send to the client the phone number of this name stored in the list.
If message is REMOVE with a name, server has to remove this name and number associated with this name from the list.
If there is an erroneous message, server should react by sending an appropriate message to the client
Clients are Java console applications that start with a connection request to the server.
Server is also a Java console application that starts with an empty list of names and phone numbers.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
