Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I communicate between 2 Python programs using sockets that are on separate NATs?

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)

like image 392
holmeswatson Avatar asked Aug 17 '12 23:08

holmeswatson


1 Answers

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.

like image 127
Russell Borogove Avatar answered Oct 31 '22 18:10

Russell Borogove