Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Jan : WinInet InternetCheckConnection and InternetGetConnectedState
| Subject: | WinInet InternetCheckConnection and InternetGetConnectedState |
| Posted by: | "Joe H" (joedot..@att.net) |
| Date: | 29 Jan 2008 09:34:20 |
I' searched for more than an hour and the newest post I've seen on this
is 2003. I can't find anything in any of the winapi or winsock area and
most of the references I do find are on the defunct winapi group.
Hopefully someone can enlighten me.
I'm trying to verify an Internet connection is available before trying
to do some things. It seems InternetGetConnectedState works but I've
seen a number of posts that claim it is not reliable because if the
Internet is turned off it will supposedly still show it as available.
Anyway I would hope that four years later that things have improved on
this?
To verify I can get to our web site, I'm using the
InternetCheckConnection and I find it always reports system error 2250
"This network does not exist" unless I add the parameter
FLAG_ICC_FORCE_CONNECTION which I have found from a post has a value of
1. I have searched all of delphi and find no reference to that
constant. If I use the value 1 as the parameter in the
InternetCheckConnection it returns true. Is this just a stupid omission
from delphi and for that matter, why would I have to say to force the
connection for it to be able to ping the web site? Microsoft does not
mention requiring this parameter for the function to work but it
certainly does not work without it.
Actually I just tried it again with a zero and apparently, once it gets
a successful hit, the next time it returns true even with the zero. But
if I change the name to a bad site name, it again returns the 2250 and
will not connect again until I set the parameter to 1 again. It seems
like windows is maintaining a connection to the site once it pings it.
Is anybody really doing this? Or is there some other way to deal with
it? Like using Indy or one of the alternatives.