3 # Copyright (c) Twisted Matrix Laboratories.
4 # See LICENSE for details.
7 Returns the IP address for a given hostname.
9 $ python gethostbyname.py <hostname>
11 $ python gethostbyname.py www.google.com
14 from twisted.names import client
15 from twisted.internet import reactor
17 def gotResult(result):
21 def gotFailure(failure):
22 failure.printTraceback()
25 d = client.getHostByName(sys.argv[1])
26 d.addCallbacks(gotResult, gotFailure)