How do i check for an internet connection?

Alex Tweedly alex at
Wed Dec 7 03:56:56 EST 2005

Kurt Kaufman wrote:

> I don't remember who to thank for this one, which I modified only  
> slightly:
> on testForConnection
> put "" into testSocket
>     open datagram socket to testSocket
>     put hostAddress(testSocket) into theIPAddress
>     close socket testSocket
>     if theIPAddress is "" then
>       --it's the local machine address, so not connected
>       --may insert connection routine here
> end  testForConnection
That tests for having a *network* connection, but not for having an 
*Internet* connection.

e.g. on my laptop, connected to my home network, this yields a value 
(today it's regardless of whether the DSL line is 
connected and working or not.

I'm not even sure it adequately tests for a network connection - on a 
machine with a single network port and a static IP address, I think it 
might return that IP address even if the network was disconnected. I 
don't have a suitable machine to test that out on, and anyway the test 
would be incomplete because it could vary between OSes.

Alex Tweedly

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.11/191 - Release Date: 02/12/2005

More information about the Use-livecode mailing list