Re: How to test whether a host is reachable?



Fabian Steiner wrote:
Hello!

As the subject says I need to test whether a host computer in our
network is reachable or not. At the moment I simply attempt to connect
to a given port that is open when the machine is online:

[...]
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
sock.connect(('192.168.0.100', 80))
except socket.error:
print >>sys.stderr "Server offline"
sock.close()
[...]

Now I am wondering if there isn't any better method which would be more
general. In fact, I think of something like a python version of ping
which only tries to send ICMP packets. However, I don't know what the
code has to look like then. Any ideas or suggestions?

Thanks,
Fabian

Just because you could ping with ICMP packets doesn't mean you could
do anything with the machine. I assume that you are connecting to
do something on the machine. Just wrap what you are trying to do
in try: block. It will either succeed or fail. Handle the exeption.

-Larry
.



Relevant Pages

  • Re: How to test whether a host is reachable?
    ... On 2/22/07, Fabian Steiner wrote: ... As the subject says I need to test whether a host computer in our ... I think of something like a python version of ping ... network, but not if it is actually providing any services. ...
    (comp.lang.python)
  • Re: Network Problem
    ... > I am having a problem with my network, to which the solution is I ... > up samba on the Alpha, but the problem I am having is I think with the ... > the Alpha I can ping all nodes on the network apart from the XP box. ... Connection Firewall turned on it may be set to block ICMP packets. ...
    (comp.unix.admin)
  • How to test whether a host is reachable?
    ... As the subject says I need to test whether a host computer in our network is reachable or not. ... I think of something like a python version of ping which only tries to send ICMP packets. ...
    (comp.lang.python)
  • Re: Mshome is not accessible
    ... Windows Network, and select the workgroup I get: ... Mshome is not accessible. ... All computers are running Windows XP SP2 and are members of the MSHOME ... Computer A can ping using ping hom100fr001. ...
    (microsoft.public.windowsxp.network_web)
  • network slowness/freez-up since update 10/11
    ... network problems: first the network is slow (even within a few ... network - but not the rest of the system - just locks up (can't ping ... OHCI version 1.0, legacy support ... <Parallel port bus> on ppc0 ...
    (freebsd-current)