UDP-TCP hole punching

Posted on July 14, 2006

I’ve been reading a lot about hole punching. With hole punching, you can get past routers and allow peer to peer communication. The problem is that you can always connect to an outside host, but when an outside host is trying to connect to you, your router doesn’t know who to forward the communication to. This is because all computers on your LAN have the same outside WAN IP. In general, you bind multiple sockets to the same local IP and port. With one of the sockets you connect to a public server, known as a rendezvous server, your router then makes a hole for your local address and port. You then use that same local address and port to connect to the LAN IP and WAN IP of the peer you are trying to connect to. With the same code you can even build a portable library that works on all OS’s. Very cool! :)