Skip to content

Instantly share code, notes, and snippets.

@adamstrickland
Created May 19, 2010 15:42
Show Gist options
  • Save adamstrickland/406450 to your computer and use it in GitHub Desktop.
Save adamstrickland/406450 to your computer and use it in GitHub Desktop.
def bind_alt_socket(alt_ip):
true_socket = socket.socket
def bound_socket(*a, **k):
sock = true_socket(*a, **k)
sock.bind((alt_ip, 0))
return sock
socket.socket = bound_socket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment