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

后端 未结 2 1646
情歌与酒
情歌与酒 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 17:57

    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

提交回复
热议问题