The scenario is the following. I have two machines A and B: A: Client (behind NAT) B: Server (behind NAT)
I want B to be able to listen on any given port, so that A
Hole punching is moderately well-understood for UDP communication, but it can be reliably used to set up peer-to-peer TCP streams as well. Here is the well detailed article on both TCP and UDP:
http://www.brynosaurus.com/pub/net/p2pnat/