且构网

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

Java套接字-如何模拟多个客户端

更新时间:2022-05-14 08:15:16


问题在于那些模拟客户端的IP地址不唯一

the problem is with the ip-address for those simulated clients NOT being unique

不,问题在于您只能通过其IP地址识别客户端。您应该使用IP:port,例如,通过 DatagramSocket.getRemoteSocketAddress()。

No, the problem is that you are only identifying clients by their IP address. You should use IP:port, for example, via DatagramSocket.getRemoteSocketAddress().

然后可以通过在单个主机上运行100个客户端程序实例。

Then you can test by running 100 instances of your client program in a single host.