在没有服务器的情况下连接两个客户端 [英] connect two clients without server

查看:200
本文介绍了在没有服务器的情况下连接两个客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何将客户端连接到全球服务器!

如果您想快速进行锻炼,请点击以下链接: http://cs.lmu.edu/~ray/notes/javanetexamples/

我的问题是如何在没有服务器的情况下连接两个客户端?"

服务器可能在那里听客户的声音,但是一旦他们连接好,我希望服务器不做任何事情,然后客户可以直接通话.

我的服务器在美国,客户端A在欧洲,客户端B在亚洲.客户是普通用户,他们只是运行应用程序并与其他客户联系-这是类似的概念,例如具有跨洲对等连接的团队查看器.

同样,请注意,我不想将任何内容发送到服务器,也不希望它成为客户端之间的经销商.它将使服务器始终侦听新的连接,并防止服务器忙于在客户端之间传递数据.

请帮助我. 谢谢

解决方案

我认为您的问题将是客户端(假设它们是网络上的任何典型计算机)没有众所周知的IP地址.

要让两个客户交谈,其中一个必须有效地成为服务器.但是,诸如NAT和防火墙之类的东西会阻止一台典型的计算机仅打开可用于Internet上其他任何计算机的监听套接字.

您的问题有点像旧的FTP协议的活动"模式,在该模式下服务器连接回客户端.这种模式在现代世界中很难使用,因为服务器的客户端IP地址概念可能是客户端专用网络的NAT网关的IP地址,而客户端IP地址的客户端概念将是私有的.网络IP地址.

I know how to connect a client to a server, world-wide!

check this link if you want to have a quick code to workout: http://cs.lmu.edu/~ray/notes/javanetexamples/

My question is "how can I connect two clients without the server?"

The server might be there to listen to clients, but once they connected, I want the server out of the deal and then clients can talk directly.

My server is in U.S., client A is in Europe and client B is in Asia. Clients are regular users and they just run the app and contact with other clients - it is a similar concept like team-viewer with the inter-continental peer-to-peer connection.

Again, please notice that I don't want to send anything to the server and I don't want it to be the dealer between clients. It will keep the server to always listen to new connections and prevents it from being busy delivering data between clients.

Please help me on this. Thanks

解决方案

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.

这篇关于在没有服务器的情况下连接两个客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆