Checking if the computer is online

Mickel Grönroos mickel at csc.fi
Thu Sep 18 03:36:33 EDT 2003


On Thu, 18 Sep 2003, Thomas Heller wrote:

> Mickel Grönroos <mickel at csc.fi> writes:
>
> > Hi all,
> >
> > I have a silly question. Is there are simple way to check if the computer
> > is connected to the Internet? It seems this should be a pretty
> > straight-forward thing to do, but as I am totally unfamiliar with sockets
> > and such, I ask for your help before getting my hands dirty.
>
> For windows?
>
> <http://article.gmane.org/gmane.comp.python.windows/969>

I want to get this done on both Windows (2000/XP) and (Redhat) Linux (7.x
or higher).

Isn't there a way to wrap a call to urllib.urlopen in some kind of timer,
so that the call fails if there is no answer in N seconds? (I.e. if
urllib.urlopen cannot open a specific web page in N seconds, then I
assume that the reason is that the computer is not online.) That would be
good enough for me. Any suggestions?

/Mickel





More information about the Python-list mailing list