我正在尝试通过 tcp 建立 p2p 网络
我正在使用 Indy 组件包。实际上,我成功地通过 udp 建立了 p2p 网络,现在仍然可以工作,但是使用 udp 我需要每次发送一些 ping 包,否则路由器将删除映射端口列表中的虚拟端口!对于视频、声音或游戏项目,通过 udp 是最好的方法,但对于我的项目,我需要通过 tcp。
我是怎么做的:我有1台服务器机器拥有一个真实的IP,所有客户端在切换到p2p模式之前都需要将包发送到服务器,现在服务器知道路由器上创建的所有客户端虚拟端口(输出端口),如果某些客户端想要发送数据到另一个客户端,他只需要将数据发送到另一个客户端的IP和路由器上的虚拟端口。路由器可以自动映射。
我在 tcp 中尝试了同样的方式,客户端将数据发送到另一个客户端 IP 和虚拟端口(在路由器上),但 tcp 客户端组件无法接收它!使用 udp 它可以接收
为什么通过 tcp p2p 拓扑与 udp 不同
或者如何使用 idtcpserver 组件将数据发送到服务器计算机以在路由器上创建虚拟端口
I am using Indy components pack for it. Actually I am succeed to make p2p network over udp and it's still working now, but with udp I need to send some ping package every time, otherway the router will remove the virtual port in mapping port list! For video or sound or gaming project over udp is the best way but for my project I need it over tcp.
How I did: I have 1 server machine owned a real ip, all clients before swiching to p2p mode need to send package to the server, and now server know the all clients virtual port (out port) maked on the router, if some client want to send data to another client, he just need to send data to another client ip and virtual port on router. Router can map it automatically.
I was try same way in tcp , the client was send data to another client ip and virtual port (on router) but tcp client component can't receive it! With udp it can receive
Why over tcp p2p topology different then udp
Or how can I send data to server machine using with idtcpserver component for create a virtual port on the router
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将
套接字
与TCP 绑定。 UDP 的绑定方式不同。TCP 和 UDP 之间的区别
在您拥有的软件包中(如果您提供它的名称,您可能会获得更多帮助)应该是连接到服务器的客户端的某种
连接/套接字/绑定
。您需要将数据发送到该连接。You bind
sockets
with TCP. UDP are not bound the same way.Difference between TCP and UDP
In the package that you have (if you provide the name of it you might get more help) there should be some sort of
connection / socket / binding
to the client that is connecting to your server. It is that connection that you need to send data to.