Skip to content

Instantly share code, notes, and snippets.

@sgk
Created November 25, 2012 04:11
Show Gist options
  • Save sgk/4142364 to your computer and use it in GitHub Desktop.
Save sgk/4142364 to your computer and use it in GitHub Desktop.
Whois query
import socket
def whois(host, query):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, 43))
sock.send(query + '\r\n');
text = ''
while True:
t = sock.recv(1024)
if not t:
break
text += t
sock.close()
return text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment