[Gambas-user] How to find out internet status

tobias tobiasboe1 at ...20...
Sun Apr 3 14:27:19 CEST 2011


hi,

this for sure isn't the best solution but my first thought was using 
ifconfig to determine if your internet interface (maybe eth0 or 
whatever) has an ip address which should mean that it is connected..? (i 
don't know how it works with a modem)
this way you are at least independant of a test server.

another way may be found according to the following test:
in my case, i am connected to the internet via wlan0. my eth0 isn't 
connected to anything. in a terminal:
$ curl --interface wlan0 google.de
returns some html, while
$ curl --interface eth0 google.de
throws "curl: (7) Couldn't bind to 'eth0'"

but if i bring my inet connection with wlan0 down
$ curl --interface eth0 google.de
and
$ curl --interface wlan0 google.de
both will give "curl: (6) Couldn't resolve host 'google.de'"

if you look up the class Net in gb.net you'll find that there are status 
codes for those cases. so, if you haven't got a connection we are 
dependent on dns. but if you specify an non-existing host in a request 
with connection to the internet you'll get the same error. so far you 
are dependent of a test server again.

maybe this test inspires you...

regards,
tobi




More information about the User mailing list