Checking for internet access
Kaelin Colclasure
kaelin at acm.org
Tue Jan 15 11:59:00 EST 2002
On 1/14/02 7:55 PM, "andu" <undo at cloud9.net> wrote:
> Sarah Reichelt wrote:
>>
>> Thanks, Andu. That works OK, except that if there is no link, the computer
>> looks like it has hung for 45 seconds. It stops completely and can't process
>> any pending messages, even the menubar clock stops.
>>
>> Is there any way to shorten the timeout interval? The socketTimeOutInterval
>> has no effect.
>
> I don't think so, it's the system and it sounds like a Mac.
This is not a good way to check for a connection on any machine. What you
are doing is sending a DNS request packet off into the ether. If you are
connected (and your machine is correctly configured), you'll generally get a
DNS response fairly quickly. But if you are not connected, the process
making the request will hang in the resolver libraries for the full DNS
request timeout.
There is no *portable* way to tell if a host has a connection or not. And
even the OS specific stuff (like querying and interface to see if it is up,
or has a carrier) is not 100% reliable. After all I may plug my machine into
a hub that isn't plugged into anything else.
I'd suggest you take a tip from how mail clients deal with this issue: Just
let the user tell you if she's working offline. Most will try a
(non-blocking) request, and present a dialog to the user if there's no
response within a reasonable timeout period.
-- Kaelin
>
>>
>> Cheers,
>> Sarah
>>
>>> Sarah Reichelt wrote:
>>>>
>>>> I thought I had a name :-(
>>>>
>>>> It may be relevant that I am behind a router which allocates me an IP
>>>> address like 192.168.1.x by DHCP. The router uses NAT to translate the
>>>> connections single IP address to different addresses on the network. I am
>>>> assuming that if I had a direct connection, hostName() would give me an
>>>> answer.
>>>>
>>>> Thanks for trying - I hope someone can come up with an answer.
>>>
>>> I didn't follow this but you can do a host name to address translation
>>> with any host name:
>>> get hostnametoaddress("www.runrev.com")
>>> if the result is empty then put it
>>> else put the result
>>>
>>>>
>>>> Sarah
>>>>
>>>>> that probably means you have no "name".. obviously this works fine for me,
>>>>> but that doesn't help you ;-) i'll keep looking into this for you, if
>>>>> anyone else has any ideas please share..
>>>>>
>>>>
>>>>>> This doesn't work for me. After a long delay (long enough to think the
>>>>>> computer has hung), it returns empty even though I am definitely
>>>>>> connected
>>>>>> at the moment. hostName() by itself is the same.
>>>>
>>>>>>>
>>>>>>> hostNameToAddress(hostname())
>>>>>>>
>>>>>>> if it's empty, there's no internet connection..
>>>>>>>
>>>>
>>>> _______________________________________________
>>>> use-revolution mailing list
>>>> use-revolution at lists.runrev.com
>>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>>
>>> --
>>> __________________________
>>> Regards, Andu
>>> _______________________________________________
>>> use-revolution mailing list
>>> use-revolution at lists.runrev.com
>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>>
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list