Java: I don't get the messages from other clients?

后端 未结 2 413
無奈伤痛
無奈伤痛 2021-01-26 17:30

does anyone know whats wrong with my code?
When I write something with client1 i just see it on the server and on the client1 but not on client2.

run() in Client.j

2条回答
  •  后悔当初
    2021-01-26 18:11

    In your handler:

    while((s = reader.readLine()) != null) { writer.write(s + "\n"); writer.flush(); System.out.println(s); }

    You are only writing the string back to the sender, not to all connected sockets

提交回复
热议问题