How do i check for an internet connection?
Alex Tweedly
alex at tweedly.net
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 "255.255.255.255:43222" into testSocket
> open datagram socket to testSocket
> put hostAddress(testSocket) into theIPAddress
> close socket testSocket
> if theIPAddress is "127.0.0.1" 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 192.168.1.67) 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 http://www.tweedly.net
--
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