I ran into precisely the same problems when trying to do precisely the same thing.
And I bet there are several other guys out there trying to add a "check for updates" feature to their applications.
'just want to motivate you to post an article on this topic as soon as you found a solution.
Take care,
Peter
Solutions in the embedded- software area: www.gliwa.com
You're absolutely right, and of course when i come across a fail safe (or somewhere close to) method, you can be sure I will write an article on it.
You would expect this to be a fairly simple procedure given that the internet forms an essential line of communications for todays software.
You can bet there is a simple api call to ascertain connection state, but most likely kept completely secret by microsoft
There are many ways of determining connected state, and many api's for this purpose. But not of them is reliable in its own right. I somehow think the solution will be a mixture of a number of api calls and socket functions.
It also seems to be the case that with most of the api's, if the connection state changes while your application is runing, they will continue to return the initial result from the first call, so if connected at startup, it will always return connected, even if you hang up. Perhaps a solution may be to call an external application/dll to ascertain the connected state, then send the result to your application. The external app/dll then exits - so when invoked again it may hopefully give the correct result.
Dunno, just thinking out loud.
Anybody want to make a "project" of this ? I'm sure if a few of use get our heads together, collectively we can find a solution.
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
Well after reading all these reply ..I Have come to know that it is easy with dialup connection...But difficult with Cable Modem.
But my question is that if cable modem is directly connected to my computer then will RASEnumConnection will work or not.My Emphasis is on"IF MY CABLE MODEM IS DIRECTLY CONNECTED TO MY COMPUTER"
And is there someway of gettting some event on this.
cauz checking the connection after sometimes is not a good solution.
With this two functions.
RasEnumConnections
RasGetConnectStatus
When ras is not installed,
your application won't start
under Winnt, so you have to
address the ras dll your self.
It also should detect DSL connections.
In order to find out which Phone book entrie it is,
which is connected, you have to match this against
RasEnumEntries()
Unfortunately, I already use these RAS api's in the way that you describe.
If the ras.dll is not available, I use wininet functions as a backup.
The problem with the ras a pproach (in fact, it seems to be a common problem amongst all methods), is that if i disconnect during the lifetime of the program which checks the connection, it will continue to tell me that i am connected. This is certainly true when using a cable modem / router. If i disconnect the cable between my nic and my router (therefore losing all network and internet connectivity), those RAS functions will tell me i am still connected
Jase
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
why dont ya use the InternetGetConnectedState(,) function
just don't forget to include the wininet.h file and to link with the wininet.dll file here is a simple code i wrote as an ex.
DWORD connection;//connection parameters return as if lan or dial
//up connected see the msdn
if(InternetGetConnectedState(&connection,0))
{
m_bConnected=TRUE;//set our status to connected
}
else//we are not connected
{
m_bConnected=FALSE;//set our connected status to false
}
U can Call the internetgetconnectedstate function many times and it works just fine for me in a win98 pc
Originally posted by leyusha
why dont ya use the InternetGetConnectedState(,) function
... because it doesn't work !
Jase
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
Just having a dialup connection configured on your pc is often enough for IGCS() to tell you are connected - doesn't matter whether or not you are actually connected.
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
i read this post and think it the most detailed one this subject.
i want to check the state of the internet........ the alogrithm that something like what voidspace has put forward only thing i will write my own socket with connection timeout.
jenis i think u have done a lot of R&D on the subject please suggest if it the right approach. As i donot have much of the testing environment and also donot want to reinvent the wheeel again.
i think u have done a lot of R&D on the subject please suggest if it the right approach. As i donot have much of the testing environment and also donot want to reinvent the wheeel again.
... reinventing the wheel is only a bad thing if you know what a wheel looks like and how it operates in the first place. The problem with this internet connection wheel is that nobody yet published how to make it, and it's not visible to copy
For sure there are many different ways of tackling this one, reading this thread from the start gives a pretty thorough list. The trick i, i believe, is to create a solution which combines these methods in a smart way.
The ping/timeout issue is just no good to me - I'm not prepared to wait. The wininet functions are not reliable. The RAS functions are not reliable. gethostbyname is not reliable. none of it seems reliable But there must be a magic method, because every time i fire up internet explorer, it knows instantly if i am online or not, regardless of my connection type.
I'm still searching for the holy grail. If any other contributors would like to step forward and share some ideas, I'd love to hear them
Jase
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
Originally posted by jase jennings
There must be a way. How do internet browsers know whether or not you are connected to the net ? There absolutley has to be a fool proof way, and it's probably undocumented ...
Jase
If you do discover a "fool proof way", then the experts probably are interested in knowing about it. See the How do I detect if there is an Internet connection? question and answer in the Winsock Programmer's FAQ: Intermediate Winsock Issues.
Hey guys,
I am worried about my code , I have used InternetGetConnectedState function from WinInet library.
Can you tell me where does it fail to detect internet connection ?
Bookmarks