connect two clients without server

别等时光非礼了梦想. 提交于 2019-12-01 13:19:13

I think that your problem will be that clients (assuming that they are any typical machine on the net) do not have well known IP addresses.

For two clients to talk, one of them will effectively have to become a server. However, things like NAT and firewalls prevent a typical machine from just opening a listening socket that is available to any other machine on the internet.

Your problem is a little like the 'active' mode of the old FTP protocol, where the server connected back to the client. This mode is difficult to use in the modern world because the servers idea of the IP address of the client is likely to be the IP address of the NAT gateway of the client's private network, and the clients idea of its IP address will be a private network IP address.

I found this http://www.lenholgate.com/blog/2005/11/windows-tcpip-server-performance.html doing some experiments.

If that is the case, then keeping the connections will not harm me for <3k active connections.

however, what I found in my local tests is that the worst part of client/server is the amount of time it needs to process the requests.

Although I am using threading, but we all know that threading is a fake thing to allow all part of the program run simultaneously. It is the bottleneck of the process and I have to optimize the algorithm for that part.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!