Internet checking?

Ralph DiMola rdimola at evergreeninfo.net
Fri Mar 2 15:40:36 EST 2018


If the FQDN's IP is cached you will get timeouts when there is no network connection. A DNS cache entry is valid until TTL is exceeded. If the DNS cache entry is stale or not cached then you will get "unknown host" when there is no network connection.

I check the network availability in my mobile apps by:
1) Set the network timeout to 2 seconds.
2) Send an https request to a webpage that calls an LC server script.
3) If there is a network connection then script returns turns an LC array with the "Status" key value of "OK". I set the app to "Network Available".
4) If there is a timeout I set the app to "Network Not Available".
5) Set the network timeout back to the previous value.

I don't check the tsNet error to find out why the "ping" failed.
I have a timer set to check if the network is up periodically.
 
Ralph DiMola
IT Director
Evergreen Information Services
rdimola at evergreeninfo.net


-----Original Message-----
From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On Behalf Of Bob Sneidar via use-livecode
Sent: Friday, March 02, 2018 3:02 PM
To: How to use LiveCode
Cc: Bob Sneidar
Subject: Re: Internet checking?

Yes, trying to figure out WHY the connection failed is trickier. I think you are right that Safari pings an IP (to exclude DNS problems) and then looks at the response. A ping that has no route will report something like Destination Unreachable as opposed to timeout. On my Apple terminal, if I ping a bogus DNS name, I get cannot resolve <hostname>: unknown host. If I ping a bogus IP, I get a timeout. If I disable all network adapters I get a timeout AND sendto: No route to host. Windows probably does something similar. 

I suppose you could simply ping through a shell and then peruse the responses. 

Bob S


> On Mar 2, 2018, at 10:09 , Graham Samuel via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Bob of course you’re right - in my particular case, anyway, I just want to know if I can access me chosen server or not.
> 
> But one could certainly imagine programs that would want to know if they were wasting their time offering their users a broader internet access - I mean any program that allows the user to specify addresses (like a browser does) would want more of an “is there or isn’t there?” approach. On my Mac, the Apple browser Safari can announce “you are not connected to the internet”. Maybe it just pings a trusted source and waits for a reasonable time for the reaction.
> 
> Anyway what I noticed in my little experiment was that the reaction of the script when the internet wasn’t available was very rapid (certainly less than half a second), which means that just trying to get the file and then looking for an error response would probably be OK for a human user, since there is no prolonged wait.
> 
> As you see, I am reluctant to do anything that’s at all complicated!
> 
> Graham

_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list