Checking if the computer is online

Thomas Bellman bellman at lysator.liu.se
Thu Sep 18 10:46:14 EDT 2003


Mickel Grönroos <mickel at csc.fi> wrote:

> 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.

First of all you need to define what "being online" means...

Is it that your modem has dialed up your ISP and been able to
establish a PPP connection?  What if you don't use a modem, and
instead have ethernet straight into your ISP's network equipment?
If the link to your ISP's closest network equipment (switch/
router/PPP dialin) is up, but the link out from that is down --
are you "online" then?  Are you online if all the links within
your ISP is up, so you can reach everyone connected to the same
ISP, but their peering is broken so you can't reach anyone else?
What if there is a firewall somewhere between you and "The
Internet", blocking you from accessing many sites, are you
"online" then?  How large part of Internet do you need to be able
to reach to claim that you are "online"?  Or must perhaps the
Internet be able to reach *you* before you are considered to be
online?  (That means that a NAT box immediately makes you offline;
I tend to like that definition. :-)

Or perhaps you should tell us *why* you believe you need to check
if the computer is connected to the Internet or not.  Then we can
go directly to telling you that it is a bad idea, and suggest what
you should do instead. <0.5 wink>


-- 
Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
"I don't think [that word] means what you    !  bellman @ lysator.liu.se
 think it means."   -- The Princess Bride    !  Make Love -- Nicht Wahr!




More information about the Python-list mailing list