Catching very specific exceptions
roy at panix.com
Sun Jan 22 23:17:01 CET 2006
"Harlin Seritt" <harlinseritt at yahoo.com> wrote:
> I am finding that with the many quirks (and really bad foundation for
> Win32 APIs) that I am having to write a lot of voodoo code so to speak.
Yeah, tell me about it. My current project at work is porting our IPv6
management package (including ICMP ping) to windows; "many quirks" would be
a good way to describe it!
> If I use a dummy port... let's say port 10001 for example... I can
> attempt to connect to a machine at this port. If I get an error that
> says "Connection refused", I know that the node is up but is just not
> going to allow a connection.
Maybe. It could be that some firewall between you and the target is
blocking things. Depending on how the firewall is programmed, this may
show up as a timeout or as a connection refused (although the former would
be more common).
It's also not always a clear-cut question what "up" means. Some operating
systems can get into modes where for all intents and purposes they've
crashed, but they're still answering pings and/or actively refusing
The traditional way to tell if a node is up is to send it an ICMP echo
request, rather than trying to connect to a TCP port. You might want to
look into using that instead of trying to connect to random ports. Not
that that ICMP doesn't have its own problems :-)
More information about the Python-list