Detecting an internet connection.
My application connects to the internet to check for updates.
It does so using functions in ras32.dll (RasGetConnectStatus)
If ras32.dll does not exist, I use win inet functions (CInternetSession::OpenURL)
Two problems :
1. If not connected, the wininet functions take a while to time out. I always call it in a thread which i timeout after 5 seconds, but still it's not perfect.
2. RAS functions only work when an internet dialup is present. If you have cable modem / router / lan, RAS will always return "not connected", even if you are.
I read a newsgroup posting from a microsoft guy who suggested also using IsNetworkAlive() and IsDestinationReachable(), but both of those fail for me, regardless of connection state.
I have writtten a class which works well for dialup connection. But in the case of "always on" connections, I have yet to find a good method for detection of internet availability.
Any suggestions guys ?