Testing internet connection

This forum is for general support of Xbase++
Message
Author
Piotr D
Posts: 129
Joined: Mon Jul 28, 2014 1:26 am
Location: Poznań, Poland

Testing internet connection

#1 Post 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

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Testing internet connection

#2 Post by rdonnay »

You can always test https;//google.com first to see if the internet is available.
The eXpress train is coming - and it has more cars.

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: Testing internet connection

#3 Post 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:
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Testing internet connection

#4 Post 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.
Best regards,

Chris.
www.aboservice.be

Piotr D
Posts: 129
Joined: Mon Jul 28, 2014 1:26 am
Location: Poznań, Poland

Re: Testing internet connection

#5 Post 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

User avatar
pedroah
Posts: 28
Joined: Wed Nov 05, 2014 7:15 pm
Location: Dominican Republic
Contact:

Re: Testing internet connection

#6 Post 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

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Testing internet connection

#7 Post by rdonnay »

DLLFUNCTION InternetGetConnectedState( Integer1, Integer2 ) USING STDCALL FROM WinInet.DLL
Thanks for that. Much better solution.
The eXpress train is coming - and it has more cars.

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Testing internet connection

#8 Post by skiman »

Hi Pedro.

FUNCTION VerifyInternet()

Thanks for this function. I will implement this today. :dance:
Best regards,

Chris.
www.aboservice.be

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: Testing internet connection

#9 Post by unixkd »

Why not

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

Thanks.

Joe

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Testing internet connection

#10 Post by rdonnay »

Return ( InternetGetConnectedState(0,0) <> 0 )
Much better. Now everything is perfect!!!
The eXpress train is coming - and it has more cars.

Post Reply