[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Network status
From:       Thiago Macieira <thiago.macieira () kdemail ! net>
Date:       2005-02-15 3:27:41
Message-ID: 200502150127.48953.thiago.macieira () kdemail ! net
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


Nathan Toone wrote:
>Any pointers on going about doing this?

The best I can tell you is to check if the default route(1) is present. 
That covers some 90%(2) of the cases. The other 10% are people with 
default routes present but no Internet, and people with no default route 
but Internet connectivity.

How you will do that, I don't know. You could try some low-level ioctls in 
order to read the routing table. Or you could try and parse the output of 
`/sbin/route -n` or `netstat -rn`. I am sure you will have a nice time 
figuring out all the possible formats for all platforms you want to run 
the code on.

(1) default route = route with a /0 (0.0.0.0) netmask
(2) 78% of the statistics are invented

Another solution would be to try and do whatever you want, or load 
Google's homepage. If it fails, it's likely connectivity is down.

-- 
  Thiago Macieira  -  thiago (AT) macieira (DOT) info
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

5. Swa he géanhwearf tó timbran, and hwonne he cóm, lá! Unix cwæð "Hello, 
World". Ǽfre ǽghwilc wæs glæd and seo woruld wæs fréo.

[Attachment #5 (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic