Communication between two computers without opening ports, using a third computer to set up the connection

后端 未结 5 1973
南笙
南笙 2021-02-03 16:19

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

5条回答
  •  轮回少年
    2021-02-03 17:00

    You're looking for rendezvous server for NAT hole punching: the server that is publicly accessible (not behind NAT/firewall or they are properly configured) to help computers behind NAT/firewall to establish peer-to-peer connection.

    UDP is more popular in NAT punching because provides much better results than TCP. Clear and informative description of UDP NAT hole punching can be found here.

    If you need reliable communication, you can use reliable protocols over UDP:

    1. SCTP (libraries) - standardized one, or
    2. one of many custom protocols, e.g. RakNet (I used this library, it's quite mature and feature-rich and has NAT punching implementation), Enet or many others (Q8)

提交回复
热议问题