Checking for an internet connectio
Dar Scott
dsc at swcp.com
Sat Apr 28 18:40:14 EDT 2012
Hi, Peter,
I like Phil's solution, but it does answer a slightly different question from you said you want to ask. I think it is a better question. It answers not only if there is an Internet connection but also whether your update server is online and reachable. That might be more of the question you wanted your script to ask. It does not say whether there are ftp/http services available on your download server.
You might want to check with a quick ping by hand to make sure icmp services are available on you server (which they are likely to be).
Dar
On Apr 28, 2012, at 2:24 PM, Peter Haworth wrote:
> Great, thanks a lot Phil, I'll give that a whirl.
> Pete
> lcSQL Software <http://www.lcsql.com>
>
>
>
> On Sat, Apr 28, 2012 at 12:30 PM, Phil Davis <revdev at pdslabs.net> wrote:
>
>> Hi Peter,
>>
>> I use "ping" to see if a given server is available. There are fewer bad
>> things that can happen using this approach than trying to get a URL. The
>> following code came from a recent project (slightly modified to protect the
>> innocent) - watch line wraps:
>>
>>
>> on mouseUp
>> answer "Connection status =" && app_connectionStatus("google.**com<http://google.com>
>> ")
>> end mouseUp
>>
>>
>>
>> function app_connectionStatus pTargetDomain
>>
>> -- attempt to ping the ctrainweb.com server
>> switch (the platform)
>> case "MacOS"
>> put shell("ping -c 1 -t 5" && pTargetDomain) into tShellOutput
>> put the result into tResult
>> break
>> case "Win32" -- PD 20100411
>> set the hideConsoleWindows to true
>> put shell("ping -n 1 -w 5" && pTargetDomain) into tShellOutput
>> put the result into tResult
>> break
>> default -- all other OSes
>> answer "This app cannot run on the" && the platform &&
>> "platform."
>> put param(0) & colon && the platform && "platform not
>> supported" into tResult
>> break
>> end switch
>>
>> -- check for connection failure
>> if tResult <> empty
>> then return false -- failed
>> else -- connected, but how well?
>> set the itemDel to comma
>> if the platform = "Win32"
>> then
>> get tShellOutput
>> filter it with "*(0% loss)*"
>> else -- Mac
>> repeat for each item tFilter in "* 0% packet loss*,* 0.0%
>> packet loss*" -- for different OS versons
>> get tShellOutput
>> filter it with tFilter
>> if it <> empty then exit repeat
>> end repeat
>> end if
>> return (it <> empty)
>> end if
>> end app_connectionStatus
>>
>>
>> HTH
>> Phil Davis
>>
>>
>>
>>
>> On 4/28/12 12:12 PM, Peter Haworth wrote:
>>
>>> Just put together a procedure for checking for software updates from my
>>> SQLiteAdmin program. All works great but I'm wondering the best way to
>>> check if there is an internet connection. I tried this out by
>>> disconnecting my computer from my wireless router and I got an"invalid
>>> host
>>> address" message from libURLErrorData as soon as I called
>>> libURLDownloadToFile.
>>>
>>> I can easily check for that of course but it sounds like that message
>>> could
>>> come back in other circumstances so wondering if there's some other way to
>>> check for an internet connection before attempting a download.
>>>
>>> Pete
>>> lcSQL Software<http://www.lcsql.com>
>>> ______________________________**_________________
>>> 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<http://lists.runrev.com/mailman/listinfo/use-livecode>
>>>
>>>
>> --
>> Phil Davis
>>
>>
>> ______________________________**_________________
>> 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<http://lists.runrev.com/mailman/listinfo/use-livecode>
>>
> _______________________________________________
> 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