How to ping a machine in a simple way?

Graham Fawcett graham__fawcett at hotmail.com
Tue May 13 22:53:10 EDT 2003


"Lexy Zhitenev" <zhitenev at cs.vsu.ru> wrote in message news:<b9rbmk$29ke$1 at serv.vrn.ru>...
> Hello, All.
> 
> I need to know if a remote host is available or not.
> I have to ping it from Python.
> I can't create SOCK_RAW sockets, so ping package can't help me.

I wonder what you mean by "available?" Perhaps a ping is the wrong
test, depending on what you're planning to do based on the results of
the test.

Are the hosts all machines that you manage, or are you looking for a
generic solution for any Internet host?

Just out of curiosity, why can't you use raw sockets? 

> My friend in Java just creates a socket on 139 port, and if it fails - the
> machine is not available.

Port 139 (netbios-ssn) is certainly not guaranteed to be open on any
given host, nor can any ping-like test to that (or any!) port be
considered reliable when firewalls are brought into play.

-- Graham




More information about the Python-list mailing list