Skip to content

Instantly share code, notes, and snippets.

@whilp
Created June 14, 2011 10:56
Show Gist options
  • Save whilp/1024678 to your computer and use it in GitHub Desktop.
Save whilp/1024678 to your computer and use it in GitHub Desktop.
Test if an IP is active
>>> import socket
>>> s = socket.socket(socket.AF_INET)
>>> s.bind(("127.0.0.1", 0))
>>> s.bind(("10.0.0.1", 0))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in bind
socket.error: [Errno 22] Invalid argument
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment