socket.gethostbyaddr() question

Harlin Seritt harlinseritt at
Sun Jan 15 10:47:54 EST 2006

I have a list of IP addresses I am testing with socket.gethostbyaddr().
For the most part, I am able to get a hostname returned to me when I
run gethostbyaddr(). I am also hoping this will allow me to tell if a
computer is up or down. However, in my environment, I am finding that I
am able to get a hostname even though I am unable to actually ping that
server (when I ping a server i like this, I get 'request timed out'
messages telling me that the server is not up).

Other times, I am able to ping a server with success but the
gethostbyaddr() request will not be able to return a hostname for me
making me think that machine is truly down when I know it's not. Can
anyone give me any pointers as to why this happens? Is there anyway I
can do a reliable ping to another server with Python? I am not
interested in doing system calls with a system Ping client (I have to
ping way too many machines and this either takes too long or causes
severe memory leakage due to MS's horrible ping client). Also, I am
unable to use Jeremy Hylton's Python ping client because it does little
more than call gethostbyaddr(). Thanks for taking a look at this.

Harlin Seritt

More information about the Python-list mailing list