Checking for an internet connectio

Peter Haworth pete at lcsql.com
Mon Apr 30 14:50:52 EDT 2012


Thanks for sharing it Phil.  It seems to be working fine for me.
Pete
lcSQL Software <http://www.lcsql.com>



On Mon, Apr 30, 2012 at 10:48 AM, Phil Davis <revdev at pdslabs.net> wrote:

> Hi Bob,
>
> Have at it! You and others have expressed great ideas for improvements,
> given various changes in the context and purpose for which it might be
> used. I'm just glad to share it, and it's fun to see others adapt it for
> their needs (and offer suggestions for core improvements).
>
> Phil
>
>
>
> On 4/30/12 8:41 AM, Bob Sneidar wrote:
>
>> Nice function. Simple and effective. What might make this a tad more
>> better is to have a list of 5 domains, in case for some reason Google ever
>> goes away or renames itself (hey it could happen!). Also, an alternate FTP
>> method might be nice upon failure of ping, as some techs block ICMP at the
>> firewall.
>>
>> Bob
>>
>> On Apr 28, 2012, at 12:30 PM, Phil Davis 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<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>
>



More information about the use-livecode mailing list