Is it the right flow for TCP hole punching for p2p application:
-
29-10-2019 - |
题
- Using stun I will get my external ip/port and NAT type.
- On my middle server (public ip), I will register peers external ip/ports (Now server knows peer 1's and 2's external ip/port).
- Exchange the ip/port (peer 1 will get to know the peer 2's ip/port).
- Simultaneously make
connect()
call from both the peers.
Is it the right flow?
解决方案
Your algorithm is correct for UDP. Take a look at these posts for more information:
其他提示
Hole punching with TCP is more complicated that what you have described. Have a look at the Practical JXTA II book available online at scribd for a description of the NAT traversal issues you would need to solve.
不隶属于 StackOverflow