How to detect if you are connected to internet?
-
Hi, i'm creating a jabber client (a chat tool, like icq or msn). In the app, i send info to a server, and i receive from it. I use MFC CSocket. Is there any api function that checks if you are connected to internet? thanks!!!
InternetGetConnectedState
It's not a bug, it's an undocumented feature.
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
-
InternetGetConnectedState
It's not a bug, it's an undocumented feature.
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
thanks! i looked it up in msdn ( http://msdn.microsoft.com/library/?url=/library/en-us/wininet/wininet/internetgetconnectedstate.asp) , and i don't understand the following: lpdwFlags [out] Pointer to a variable that receives the connection description. This parameter can be one or more of the following values. Value Meaning INTERNET_CONNECTION_CONFIGURED Local system has a valid connection to the Internet, but it might or might not be currently connected. INTERNET_CONNECTION_LAN Local system uses a local area network to connect to the Internet. INTERNET_CONNECTION_MODEM Local system uses a modem to connect to the Internet. INTERNET_CONNECTION_MODEM_BUSY No longer used. INTERNET_CONNECTION_OFFLINE Local system is in offline mode. INTERNET_CONNECTION_PROXY Local system uses a proxy server to connect to the Internet. INTERNET_RAS_INSTALLED Local system has RAS installed. the following code always returns online.. any ideas?
unsigned long \*a; a=(unsigned long \*)malloc(sizeof(unsigned long)); if (TRUE==InternetGetConnectedState(a,0)) AfxMessageBox("online"); else AfxMessageBox("offline");
-
Hi, i'm creating a jabber client (a chat tool, like icq or msn). In the app, i send info to a server, and i receive from it. I use MFC CSocket. Is there any api function that checks if you are connected to internet? thanks!!!
kfaday wrote: I use MFC CSocket. Over
CAsyncSocket
? Why? kfaday wrote: Is there any api function that checks if you are connected to internet? See here.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
kfaday wrote: I use MFC CSocket. Over
CAsyncSocket
? Why? kfaday wrote: Is there any api function that checks if you are connected to internet? See here.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
Check out this article http://tangentsoft.net/wskfaq/articles/csocket.html
-
Check out this article http://tangentsoft.net/wskfaq/articles/csocket.html
And your point is? I'm aware of the downfalls of using
CSocket
, some of which aren't even mentioned in your article, but perhaps the OP is not.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
Hi, i'm creating a jabber client (a chat tool, like icq or msn). In the app, i send info to a server, and i receive from it. I use MFC CSocket. Is there any api function that checks if you are connected to internet? thanks!!!
See the FAQ 8.7 How do I tell if the computer is connected to the Internet?[^] --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- "Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!" -- Rico Mariani, CLR perf guy
-
See the FAQ 8.7 How do I tell if the computer is connected to the Internet?[^] --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- "Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!" -- Rico Mariani, CLR perf guy
-
See the FAQ 8.7 How do I tell if the computer is connected to the Internet?[^] --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- "Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!" -- Rico Mariani, CLR perf guy
thanks for the link to the faq
#include .
.
.BOOL bConnected;
DWORD dwFlags;bConnected = InternetGetConnectedState ( &dwFlags, 0 );
if ( bConnected )
if ( dwFlags & INTERNET_CONNECTION_OFFLINE )
bConnected = FALSE;i get this error: error C2065: 'INTERNET_CONNECTION_OFFLINE' : undeclared identifier any ideas? thanks!