RE: Internet checking?

2018-03-02 Thread Ralph DiMola via use-livecode
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
rdim...@evergreeninfo.net


-Original Message-
From: use-livecode [mailto:use-livecode-boun...@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 : 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@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


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

Re: Internet checking?

2018-03-02 Thread Bob Sneidar via use-livecode
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 : 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 
>  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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Internet checking?

2018-03-02 Thread Graham Samuel via use-livecode
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

> On 2 Mar 2018, at 16:47, Bob Sneidar via use-livecode 
>  wrote:
> 
> Hi Graham. 
> 
> Whether or not you are connected to the internet isn't really the issue, is 
> it? All that means is that you have a route to the WAN port of your edge 
> router. I mean, the real issue is finding out if you can reach a particular 
> server on a particular port using DNS, or else a given IP address, whether or 
> not it is "on the internet". That is I think, what you really mean. 
> 
> The code I posted, while it has some exterraneous code dependent on sqlYoga 
> calls, neverless is a framework for doing that. 
> 
> 1. Outer loop to allow user to retry (not strictly necessary but it lets the 
> user attempt to fix the problem before dumping him).
> 2. Inner loop to open socket to prescribed server (Not necessary either, but 
> you may want to check multiple times for the open socket in case of slow 
> connections, and timeout after x tries). 
> 
> Bob S
> 
> 
>> On Mar 2, 2018, at 03:44 , Graham Samuel via use-livecode 
>>  wrote:
>> 
>> I’m really surprised there isn’t a foolproof way to find out if one’s device 
>> is connected to the internet or not.
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


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

Re: Internet checking?

2018-03-02 Thread Bob Sneidar via use-livecode
Hi Graham. 

Whether or not you are connected to the internet isn't really the issue, is it? 
All that means is that you have a route to the WAN port of your edge router. I 
mean, the real issue is finding out if you can reach a particular server on a 
particular port using DNS, or else a given IP address, whether or not it is "on 
the internet". That is I think, what you really mean. 

The code I posted, while it has some exterraneous code dependent on sqlYoga 
calls, neverless is a framework for doing that. 

1. Outer loop to allow user to retry (not strictly necessary but it lets the 
user attempt to fix the problem before dumping him).
2. Inner loop to open socket to prescribed server (Not necessary either, but 
you may want to check multiple times for the open socket in case of slow 
connections, and timeout after x tries). 

Bob S


> On Mar 2, 2018, at 03:44 , Graham Samuel via use-livecode 
>  wrote:
> 
> I’m really surprised there isn’t a foolproof way to find out if one’s device 
> is connected to the internet or not.

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

Re: Internet checking?

2018-03-02 Thread Graham Samuel via use-livecode
Rick, thanks for the reply.

Well, sounds good, but as I have no idea of the range of happenings that could 
generate that error, I need a bit more information first!

It’s odd how hard it is to find this stuff out. If it wasn’t for the nice 
little ‘LiveCode Error Lookup’ plug-in that’s been around for ages (Jacque, was 
it you that created it?) we’d have the same problem with error numbers in 
mainline LC. Actually, perhaps one should ask the mother ship to add tsnet 
errors to the plug-in… think I will.

Graham

> On 2 Mar 2018, at 15:23, Rick Harrison via use-livecode 
>  wrote:
> 
> Hi Graham,
> 
> Why don’t you just check for the existence of "tsneterr: (7)”?
> 
> Rick
> 
>> On Mar 2, 2018, at 7:18 AM, Graham Samuel via use-livecode 
>>  wrote:
>> 
>> 2. If I switch off my internet connection, I get the result “tsneterr: (7)”
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


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

Re: Internet checking?

2018-03-02 Thread Rick Harrison via use-livecode
Hi Graham,

Why don’t you just check for the existence of "tsneterr: (7)”?

Rick

> On Mar 2, 2018, at 7:18 AM, Graham Samuel via use-livecode 
>  wrote:
> 
> 2. If I switch off my internet connection, I get the result “tsneterr: (7)”

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

Re: Internet checking?

2018-03-02 Thread Graham Samuel via use-livecode
I wrote:

> 
> Maybe I will write a tiny standalone that just talks to my server, and 
> experiment with switching off the internet connection to see what errors I 
> get.

I just did that, but so far have only used it in the IDE. I found out two 
things:

1. Despite my not being particularly interested in tsnet, if I run this program 
from the IDE, it uses tsnet. I’m not sure if it’s my responsibility to 
initialise tsnet or not, either here in the IDE (unlikely) or in a standalone 
(more likely).

2. If I switch off my internet connection, I get the result “tsneterr: (7)”

Seems interesting, so I have looked for a list of tsnet error numbers, but I 
can’t find it. Basically all I can find about tsnet is the stuff in the 
dictionary and some press releases. Can anyone point me at its error list?

TIA

Graham


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

Re: Internet checking?

2018-03-02 Thread Graham Samuel via use-livecode
Jacque, thanks. It seems like overkill to load up and initialise tsnet just to 
get a 20-byte text file. I’m really surprised there isn’t a foolproof way to 
find out if one’s device is connected to the internet or not. I am not good on 
internet functions, but don’t a huge number of apps in the real world want to 
know if they’re connected or not?

Maybe I will write a tiny standalone that just talks to my server, and 
experiment with switching off the internet connection to see what errors I get.

Puzzled

Graham

> On 1 Mar 2018, at 06:47, J. Landman Gay via use-livecode 
>  wrote:
> 
> On 2/28/18 5:20 PM, Graham Samuel via use-livecode wrote:
>> I know this is a golden oldie, but I can’t find a reference… I have a script 
>> that wants to check a file on a server, and basically to do nothing if the 
>> program is offline.
>> Remind me, is there an easy way to tell from within an LC standalone if the 
>> internet is not accessible? I don’t want my program to hang. I understand 
>> the URLStatus will eventually tell me if access did not occur, but I don’t 
>> understand how to limit the waiting time to something reasonable. I notice 
>> that some browsers can actually display a message saying something like “you 
>> are not connected to the internet” - how do they do that?
> 
> I haven't actually played with it, but it looks like tsNetSetTimeouts might 
> work if you set the pConnectTimeoutMS (the third param) to something shorter 
> than the default. Then when you try to retrieve your file when there is no 
> connection, you should get an error from tsNet.
> 
> -- 
> Jacqueline Landman Gay | jac...@hyperactivesw.com
> HyperActive Software   | http://www.hyperactivesw.com


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

Re: Internet checking?

2018-02-28 Thread J. Landman Gay via use-livecode

On 2/28/18 5:20 PM, Graham Samuel via use-livecode wrote:

I know this is a golden oldie, but I can’t find a reference… I have a script 
that wants to check a file on a server, and basically to do nothing if the 
program is offline.

Remind me, is there an easy way to tell from within an LC standalone if the 
internet is not accessible? I don’t want my program to hang. I understand the 
URLStatus will eventually tell me if access did not occur, but I don’t 
understand how to limit the waiting time to something reasonable. I notice that 
some browsers can actually display a message saying something like “you are not 
connected to the internet” - how do they do that?


I haven't actually played with it, but it looks like tsNetSetTimeouts 
might work if you set the pConnectTimeoutMS (the third param) to 
something shorter than the default. Then when you try to retrieve your 
file when there is no connection, you should get an error from tsNet.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com


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

Re: Internet checking?

2018-02-28 Thread Bob Sneidar via use-livecode
Here is a script I use. A lot of this stuff won't make sense because it is part 
of my interface with sqlYoga, but the core is a repeat loop where I open a 
socket to the server, then check if the socket is among the lines of the 
openSockets. If it is I exit the repeat loop and close the socket, then return 
true, otherwise I wait 1 second, then try again. After 5 failed attempts I 
alert the user and offer to try again (2 repeat loops) until t he user cancels 
in which case I exit to top. 

This has worked fairly well for me. On the flip side I religiously ensure I 
close the database connection after I am done with it, but of course you are 
using it to access a file. Same principle though. 

Bob S


> On Feb 28, 2018, at 15:20 , Graham Samuel via use-livecode 
>  wrote:
> 
> [This message was identified as a phishing scam. Learn about phishing at 
> http://aka.ms/LearnAboutPhishing]
> 
> I know this is a golden oldie, but I can’t find a reference… I have a script 
> that wants to check a file on a server, and basically to do nothing if the 
> program is offline.
> 
> Remind me, is there an easy way to tell from within an LC standalone if the 
> internet is not accessible? I don’t want my program to hang. I understand the 
> URLStatus will eventually tell me if access did not occur, but I don’t 
> understand how to limit the waiting time to something reasonable. I notice 
> that some browsers can actually display a message saying something like “you 
> are not connected to the internet” - how do they do that?
> 
> TIA
> 
> Graham
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

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