且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过Java中的服务器套接字从客户端读取并发送到另一个客户端

更新时间:2022-02-21 22:15:38

网上有许多示例.一个快速的Google提出了本教程:

There's any number of examples on the net for this. A quick google brought up this tutorial:

http://programming-guides.com/java/tcp-client-服务器聊天

您需要维护多个连接,每个客户端一个,然后在收到数据后将数据发送到相应的客户端.

You need to maintain multiple connections, one for each client, and send the data to the appropriate clients when you receive it.