Using a socket, I know I can get a response to a post message.
I know I can trap a ‘connected’ event when it connects.
I’d like to know if an internet connection is available before I try rather post and sitting waiting for a ‘train that won’t come’
Is there a way to know if an internet connection is available?
On some machines, white or blacklisting can prevent my app from dialling home.
I guess a LAN will get you Network.IsConnected = True, but it won’t say the Internet is present. Checking if Internet connectivity exists remains necessary.
I found that just asking for my homepage with an httpsocket.GET with a timeout looks like the easiest way to check.
If I get a status of 200, the site is there, and I can talk to it, so I can then proceed to risk a POST.
dim h as new HTTPSocket
call h.Get("http://www.example.com/", 30)
if h.HTTPStatusCode <> 200 then
msgbox "There may be trouble ahead, but while there's moonlight..."
end if
And what about:
Dim http As New HTTPSocket
HTTP.Address = “www.apple.com”
http.port = 80
http.Connect
if http.LastErrorCode = 0 then
//do something
//MsgBox “Connected”
end if
http.close
It SEEMS quicker that Jeff’s code. But is it 100% reliable?
Thanks.