Question re download timeout setting

Bob Sneidar bobsneidar at iotecdigital.com
Fri Jul 21 23:29:38 EDT 2023


Use sockets to test the connection. 

Open socket to <url:port> 
If the result is not empty then…
Close socket <url:port>

Sent from my iPhone

> On Jul 21, 2023, at 17:49, Alex Tweedly via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> 
>> On 22/07/2023 01:02, prothero--- via use-livecode wrote:
>> Folks:
>> Sorry for the trivial question, but..
>> I have an app on my iphone that I am updating from a several years old app the previously worked on an older version of livecode. It needs to access a mysql database on the internet. It works fine when there is internet service.
>> 
>> I test access by downloading a file with a simple text code. If there code is returned in the message, I continue accessing the database. However, when there is no internet, the "put URL” command seems to hang forever. I’ve looked for a way to set the timeout for an internet command, but…. can’t,.
>> 
>> Could you direct me to a simple explanation about how to set a reasonable internet not connected message?
>> 
> .... not thoroughly tested ....
> 
> You should, I think, be able to do this using tsNetSetTimeouts. But I wouldn't :-)
> 
> I'd do something like the following - I've tested some, but not all, failure cases, but haven't tested a successful url.
> 
> 
>> local sEventID
>> 
>> -- neverhappens.com is a website - returns "Forbidden"
>> -- nevehapens.com isn't, so almost immediately returns "can't be reached"
>> -- I didn't test a properly working case :-)
>> 
>> constant KURL = "http://neverhappens.com"
>> 
>> on mouseup
>>    load url kURL with message "gotareply"
>>    send "timetocheck failed" to me in 10 seconds     -- or whatever timeout you want
>>    put the result into sEventID
>> end mouseup
>> 
>> on gotareply pURL, pURLStatus
>>    cancel sEventID
>>    timetocheck pURLStatus
>> end gotareply
>> 
>> on timetocheck pWhat
>>    local tAnswer
>>    put "time to check" && pWhat &CR after msg
>>    if pWhat = "loaded" then
>>       put URL kURL into tAnswer
>>       if tAnswer contains "mycode" then
>>          -- Internet is good
>>          put "Internet is good" &CR after msg
>>       end if
>>    end if
>>    -- Internet problematic
>>    put "problem" &CR after msg
>>    if pWhat = "error" then put libUrlErrorData(kURL) &CR after msg
>> 
>>    unload URL KURL
>> end timetocheck
> 
> 
> Alex.
> 
> 
> _______________________________________________
> 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