I want to send and receive messages between two Python programs using sockets. I can do this using the private IPs when the computers are connected to the same router, but how do I do it when there are 2 NATs separating them?
Thanks (my first SO question)
You can't do it in general without a relay server on a publicly addressable IP address. There are so-called "punchthrough" techniques that can, in some cases, let you switch to a direct connection after using a public server to figure out port mappings - this article describes how the RakNet game networking library does it - but even these tend to be finicky and unreliable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With