Is there a way to tell if your network connection has a WWW connection?

I’ve looked in every corner I can find. Does anyone know of a reliable way to see if the network your device is attached to has a web connection? I guess I’m looking for something like System.Network.IsWebConnected() As Boolean.

Trying using SHELL to PING GOOGLE.COM

Thanks. That works, although I had to up the timeout to 4000.

I also tried System.Network.LookupIPAddress("google.com"). If it returns an empty string, then we’re not connected.

Whatever method you use, try it against several addresses in random order. The first one to succeed will mean you’re connected, but if, for example, google.com is down, you can avoid a false negative.

Good idea. Thanks!

You might check this link as well: https://forum.xojo.com/5104-checking-internet-connection

i like using this, it works every time.

if System.Network.IsConnected then
else
MsgBox “Please check your wifi or eathernet connection .”+endofline+“This app requires a network connection to operate”
end if

[quote=246395:@Russell Rhoades]i like using this, it works every time.

if System.Network.IsConnected then
else
MsgBox “Please check your wifi or eathernet connection .”+endofline+“This app requires a network connection to operate”
end if[/quote]
That tells you nothing about internet connectivity.

Pings can be black holed so they wont return so you may get false results from a ping

DNS queries are unlikely to be black holed.
But getting a name or IP for an address doesn’t tell you you can connect to the site.
You could reach the DNS but the IP it gives you is NOT reachable.

Just try & use the site and deal with the errors & timeouts

[quote=246442:@Norman Palardy]But getting a name or IP for an address doesn’t tell you you can connect to the site.
You could reach the DNS but the IP it gives you is NOT reachable.[/quote]
To expand on this further. DNS doesn’t even mean you have contacted the ‘outside’ world to get the IP address. Each DNS entry has a time to live, and the client and/or local router will not look up the address again unless this has expired. The IP address may even be an ‘old’ address if the address changed, but the timeout value has yet to expire.

You could visit google.com and a few minutes later the internet connected go down, meaning you cannot contact any site. DNS could still resolve to an IP using a previously cached value.

Exactly! You typically only want to know if your intended service is reachable, so test for that instead. Nothing else really matters.

100% what David said. To give you a living example:

I am using for my clients (and myself) IPFire.org firewalls for blocking and filtering content. The fact that somebody may conduct DNS (TCP port 53) queries or PINGs (ICMP) has nothing in common with the fact that somebody can surf the web (TCP ports 80, 443) . You are comparing apples with beans on port and protocol level.

Let me raise the bar a little higher. Even the fact that somebody gets a result string when asking for certain domain www.test.com does absolutly nothing say, that he can reach the domain. It could be a message that access to this domain is blocked or the content itself could be filtered (no ads, keywords etc.). Also companies may use whitelists, so google.com, some news sources and the companies intranet can be accessed but everything else not.

IMHO this is the best approach against cryptowall, spyware and adware… (in combination with other ad policies on windows).

I ping ‘8.8.8.8’ to test the connectivity.

As stated that tells you next to nothing about the system you ARE trying to reach & use
Heck I’m surprised 8.8.8.8 doesn’t just not respond to pings

I saw companies which have only proxy. No DNS. Just send your request to proxy at some IP and it will do DNS and return the http(s) stream you ask for.

You can only try and see if you get an error.