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
You will have to either:
Set up port forwarding from the nat gateway in front the server into the machine your server software is running, and have the client connect to the IP address of that gateway.
Create a proxy server sitting inbetween the 2 nat gatewys so both your server and client can connect to that. Both your server and client have to set up a connection to that proxy which will mediate the data between those 2 connections.