Page 1 of 2

Testing internet connection

Posted: Thu Dec 03, 2015 1:45 pm
by Piotr D
Hi,
I test internet connection usung LoadFromUrl() with an www addres. When return NIL, probably
internet connection is unavailable. But this is only probably, the web site can be currently unavailable,
and these "test" have about 10 second duration. Is another way validate connection?
Piotr

Re: Testing internet connection

Posted: Thu Dec 03, 2015 2:07 pm
by rdonnay
You can always test https;//google.com first to see if the internet is available.

Re: Testing internet connection

Posted: Thu Dec 03, 2015 4:02 pm
by bwolfsohn
rdonnay wrote:You can always test https;//google.com first to see if the internet is available.
Or to see if the earth is still there...
:violin:

Re: Testing internet connection

Posted: Fri Dec 04, 2015 1:22 am
by skiman
Hi,

Do the test at startup of your application in a separate thread and save the result. If there is no internet available on that PC, you don't have to wait 10 seconds when you want to use it.

Re: Testing internet connection

Posted: Fri Dec 04, 2015 11:11 am
by Piotr D
Roger,
I use LoadFromUrl() with web addres of my own website. But I search for an another way/function.
Chris, in case when there isn't another way, I will use your suggestion.
Regards Piotr

Re: Testing internet connection

Posted: Sun Dec 06, 2015 8:17 pm
by pedroah
DLLFUNCTION InternetGetConnectedState( Integer1, Integer2 ) USING STDCALL FROM WinInet.DLL



FUNCTION VerifyInternet()
LOCAL lReturn
IF InternetGetConnectedState(0,0) <> 0
lReturn := .T.
ELSE
lReturn := .F.
ENDIF
RETURN lReturn

Re: Testing internet connection

Posted: Sun Dec 06, 2015 8:48 pm
by rdonnay
DLLFUNCTION InternetGetConnectedState( Integer1, Integer2 ) USING STDCALL FROM WinInet.DLL
Thanks for that. Much better solution.

Re: Testing internet connection

Posted: Mon Dec 07, 2015 1:15 am
by skiman
Hi Pedro.

FUNCTION VerifyInternet()

Thanks for this function. I will implement this today. :dance:

Re: Testing internet connection

Posted: Mon Dec 07, 2015 3:14 am
by unixkd
Why not

FUNCTION VerifyInternet()
Return ( InternetGetConnectedState(0,0) <> 0 )

Thanks.

Joe

Re: Testing internet connection

Posted: Mon Dec 07, 2015 7:59 am
by rdonnay
Return ( InternetGetConnectedState(0,0) <> 0 )
Much better. Now everything is perfect!!!