Direct P2P connection

前端 未结 5 834
遇见更好的自我
遇见更好的自我 2020-12-25 10:04

This topic resembles this thread

I\'m rather new to the topic of network programming, never having done anything but basic TCP/UDP on a single local machine. Now I\'

5条回答
  •  一向
    一向 (楼主)
    2020-12-25 11:05

    You'll need a server to exchange IP address and such. As the other thread literally points out, the only way of guaranteeing a connection is to proxy through a server. Most peer to peer systems use UPnP and NAT Hole Punching (this method needs a server relaying port information and only works with UDP) to establish a connection in most cases.

    NAT Hole Punching works by both clients establishing a connection to a server, then the both try to connect directly to a port that the other has relayed to the other. Most UDP NAT remember the IP address and port for a short time, so although the data never made it to the other end (not that this matters with UDP) the other client will try to connect a few moments later to that report as the NAT would expect the reply.

提交回复
热议问题