Skip to content

Instantly share code, notes, and snippets.

@PI-Victor
Created February 14, 2015 19:35
Show Gist options
  • Save PI-Victor/de9f42cc5ac5b27a54ed to your computer and use it in GitHub Desktop.
Save PI-Victor/de9f42cc5ac5b27a54ed to your computer and use it in GitHub Desktop.
get the ip to which to bind
import socket
#get current ip to bind to
DEFAULTHOST = ([(s.connect(('8.8.8.8', 80)), s.getsockname()[0],
s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment