Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can I truly check for Internet connection?
Message
From
20/11/2002 10:29:41
 
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
00724735
Message ID:
00724761
Views:
37
This message has been marked as the solution to the initial question of the thread.
Rodd,

For a user with a LAN connection to the internet, pinging is the most reliable method. If you are concerned that an internet server may be down, then check a different server if the first one returns false.

Here is a function you can use
function checkInternetConnection
lparameters lcWebAddress

	Declare Integer InternetCheckConnection in Wininet.dll String Url, Long dwFlags, Long Reserved

	If InternetCheckConnection(lcWebAddress, 1, 0) != 0
		return .t.
	Else
		return .f.
	EndIf
endproc
Example usage:
? checkInternetConnection("http://www.microsoft.com")
>Is there truly a way to check whether or not a user has a working internet connection established?
>
>We're developing a distributed app using WebConnect on our server. Because of the remote locations of some of our clients and the instability of internet connections in many of their locations, we are developing a fat client that will perform synchronization across the net. (Reducing the amount of time they need to be connected.)
>
>Theoretically, the user will press a button to begin synchronization. At that point, I want to first determine if the user is connected to the internet. Some of our users will be using dial up; others will have a constant connection through their LAN.
>
>I've tried the API functions InternetAttemptConnect and InetIsOffline. However, on my machine (which has constant internet access via our LAN) the two functions always told me I was connected ... EVEN when I disconnected my computer from the LAN (at which point I was most definitely not connected to the internet.)
>
>Some on UT have mentioned trying to PING the server first. The only problem I see is that a failure doesn't tell you if there is no connection or if the server is down. If it's just that there is no connection, then I want to try to connect via their dial up settings. If the server is down, they may alread be connected and I don't want to pop up a dial-up dialog box.
>
>Any ideas on this?
Steve Gibson
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform