无需打开端口,采用了第三台计算机建立连接两台计算机之间的通信 [英] Communication between two computers without opening ports, using a third computer to set up the connection

查看:315
本文介绍了无需打开端口,采用了第三台计算机建立连接两台计算机之间的通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我有一台服务器,并连接到它的两个客户端。 (通过TCP,但它并不重要)

Let's say I have a server, and two clients connected to it. (via TCP, but it doesn't matter)

我的目标是让那些两个客户端之间的直接连接。这是为了使任何其他客户端插件他们可能已经安装了不需要服务器交互(如打某种随机游戏的两个之间)两个玩家之间的直接语音联系,例如,或。服务器可以在那里帮助建立连接。

My goal is to allow a direct connection between those two clients. This is to allow direct voice contact between two players, for example, or any other client plugin they may have installed which don't need server interaction (like playing some kind of random game between the two). The server can be there to help setting up the connection.

从duskwuff的回答,我有几条线索:

From duskwuff's answer, I got several leads:

http://en.wikipedia.org/wiki/STUN 的描述的算法来这样做,结果
http://en.wikipedia.org/wiki/UDP_hole_punching

http://en.wikipedia.org/wiki/STUN which describes an algorithm to do that, and
http://en.wikipedia.org/wiki/UDP_hole_punching

从这些,我得到了更多的线索:

From those, I got more leads:

http://www.h-online.com/security/features/How-Skype-Co-get-round-firewalls-747197.html

http://nutss.gforge.cis.cornell.edu/stunt.php - 一个可能的STUN实现与TCP

http://www.h-online.com/security/features/How-Skype-Co-get-round-firewalls-747197.html
http://nutss.gforge.cis.cornell.edu/stunt.php -- A possible STUN implementation with TCP

随着时间的推移,我肯定可以找出一些对我的计划。现在我使用C ++和TCP(Qt的套接字或升压插座),但如果需要的话,我不介意用C做UDP和包装它。

With time, I could surely work out something for my program. For now I'm using C++ and TCP (Qt Sockets or Boost sockets), but if needed I don't mind doing UDP in C and wrapping it.

赏金是有与C和C ++,可能会给提示,使这更容易,通过链接到示例程序,更新库,或任何其他有用的信息,任何有经验的程序员。文档化的,灵活的和放大器;工作C ++ TCP实现将是最好的,但我会采取什么我搞定!

The bounty is there for any programmer having experience with those in C and C++ that may give tips to make this easier, by linking to example programs, updated libraries, or any other useful information. A documented, flexible & working C++ TCP implementation would be the best but I'll take what I get!

推荐答案

在NAT冲压TCP打洞,有时/经常可能的(它依赖于NAT的行为)。这不是一个简单的题目来学习,而是从实用的JXTA II(可在线上Scribd)了解NAT穿越的相应章节,了解问题的性质来解决。

Punching TCP holes in NAT is sometimes/often possible (it depends of the NAT behavior). This is not a simple subject to learn, but read the corresponding chapter about NAT traversal from Practical JXTA II (available online on Scribd) to understand the nature of the issues to solve.

然后,阅读这个。它来自谁写的家伙: HTTP://nutss.gforge.cis.cornell。 EDU / stunt.php (在你的问题的一个链接)。

Then, read this. It comes from the guy who wrote that: http://nutss.gforge.cis.cornell.edu/stunt.php (one of the links in your question).

我不是一个C / C ++专家,但要解决的问题是不特定的语言。只要你有机会从code基地TCP,这就足够了。请记住,实现UDP穿透比TCP更容易。

I am not a C/C++ specialist, but the issues to solve are not language specific. As long as you have access to TCP from your code base, that's enough. Keep in mind that implementing UDP traversal is easier than TCP.

希望这些提示帮助。

P.S:我不知道一个C / C ++实现的解决方案的。由作者所证实在康奈尔大学的链接中提到的code是不可操作。我试图救活它自己,但他让我知道它是完全调整为研究目的,远离生产做好准备。

P.S.: I am not aware of a C/C++ implementation of the solution. The code mentioned in Cornell's link is NOT operational as confirmed by the author. I tried to resuscitate it myself, but he let me know it was completely tweaked for research purposes and far from production ready.

这篇关于无需打开端口,采用了第三台计算机建立连接两台计算机之间的通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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