Question: Please create a Java client and server program that is a multithreaded chat service that can do the following. Thank You. The server is a
Please create a Java client and server program that is a multithreaded chat service that can do the following. Thank You.

The server is a concurrent server and can accept multiple connections. The server program ill log and broadcast every chat message it receives from any client. For each connection, the server will create a new thread and hand the connection to it. The server then waits for the next connection The server program will create a chat file called 'xy chat.txt upon the arrival of the first connection (first client joins the chat room) and will share this file with all the subsequent connections as long as there is at least one open connection. The server will delete the chat file when the last connection is closed (the only remaining client leaves the chat room). The server will create a new chat file each time a client joins an empty chat room. Since every thread that manages the communications with a client can read from and write to the chat file, the activities of these threads must be coordinated (synchronized), otherwise things might go wrong. A thread must have an exclusive access (or a lock) to the chat file before writing to it. When a connection is made, the thread that manages the connection will wait for the user's name, and then sends the client the content of the chat file. It will also log and broadcast the arrival of a new client to the chat room. Any message from the client after this point, except DONE, will be logged and broadcasted. For DONE, the thread will log and broadcast the departure of the client from the chat room. When the client signals that it is ready to leave the chat session (sending DONE), the thread will close the client connection, and then will terminate As mentioned above, the server will log and broadcast every chat message it receives from any client. If the server gets a chat message from client A, then client A must be excluded from the list of clients that will get the message (the server doesn't echo the message back to the same client) The client program establishes a connection to the server, sends the user name over and then prepares to receive the content of the chat file. Now, the client is ready participate in the ongoing chat. The client program must have two threads in order to implement a full duple communication (ie, send and receive simultaneously). One thread sends whatever the user types at the keyboard to the server and the other thread (say the main thread) displays whatever it receives from the server. The user can leave the chat room at any time by typing 'DONE' at the keyboard, and the client program will send that message to the server and then terminate gracefully
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
