Search code examples
python-3.xip-address

Can I use the python 'socket' module for listening on my external ip? if no, is there a preinstalled module which can?


I have built a small program that listens to a port on my laptop and an other program on my phone that connects to that port on my laptop. Now this all works fine but i was wondering if that same module could be used with external ip adresses. If it doesn't work with external ip's, is there a preinstalled module that can work with external ip's?


Solution

  • If you forward that port in your network bridge (probably your all-in-one router) then yes! Simply listen on IPv4 address 0.0.0.0 or IPv6 address :: (maybe 0:0:0:0:0:0:0:0%0) to ensure that you're listening on all available IP addresses, instead of just localhost, and you're good to go.