Skip to content Skip to sidebar Skip to footer

Python Socket To Connect Over Global Public Ip Address

I have been working on a project to connect computers located in different locations together through Python. Initially, while testing, I used my private IP address (I did not know

Solution 1:

In server you always use local IP (it is IP of one of network cards in computer or 0.0.0.0 to use all network cards)

s.bind( (local_IP, port) )

# or 

s.bind( ('0.0.0.0', port) ) 

In client you use external IP

s.connect( (external_IP, port) )

External client uses external IP to connect with your Internet Provider route and this router knows that this external IP is assigned to your computer and it redirects it your server.

At the same time local client can use local IP to connect with the same server.

external_client --> router(externa_IP) --> server(local_IP) <-- local_client

Post a Comment for "Python Socket To Connect Over Global Public Ip Address"