I have a chat room, running in the console. The server supports multiple clients through thread use. When I run it, the server then the client, the client connects fine. I send a message through the client program, "hello", and the client prints out the message, indicating that the server got the message (this is what the server is meant to do). But when I run another client at the same time, I send a message on one client but the message is not printed on the other client. Why would that be the case? There are no errors, and the clients connect fine.
Regards Bl-H
I will post code upon request.
Ok this is the code for server sending message to client (this is the method from the thread class):
public void run() {
PrintStream output = null;
BufferedReader input = null;
String message;
try {
//i/o for clients:
output = new PrintStream(server.getOutputStream());
input = new BufferedReader(new InputStreamReader(server.getInputStream()));
} catch (IOException ioe) {
System.err.println(ioe);
System.exit(1);
}
while(true) {
try {
message = input.readLine();
output.println(message);
} catch (IOException ioe) {
System.err.println(ioe);
System.exit(1);
}
}
}