Question
JAVA PROGRAM PROVIDED, please just make or modify a few changes so it sucesssfully does the following things. ChatServer Progrm import java.io.*; import java.net.*; public
JAVA PROGRAM PROVIDED, please just make or modify a few changes so it sucesssfully does the following things.
ChatServer Progrm
import java.io.*; import java.net.*; public class ChatServer { static Socket clientSocket = null; static ServerSocket server = null; static ChatThread t[] = new ChatThread[10]; public static void main(String args[]) { if (args.length "+line); } } for(int i=0;i
------------------------------------------------------------------------------------------------------
ChatClient Program
import java.io.*; import java.net.*; public class ChatClient implements Runnable { static Socket clientSocket = null; static PrintStream c_output = null; static DataInputStream input = null; static BufferedReader inputLine = null; static boolean closed = false; public static void main(String[] args) { if (args.length 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 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
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