|
-
June 21st, 2004, 09:15 AM
#1
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!!!
-
June 21st, 2004, 09:39 AM
#2
If you would have searched the forums first, you would have found the following function: InternetGetConnectedState
-
June 21st, 2004, 10:08 AM
#3
thanks!!
i looked it up in msdn (link) , 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?
Code:
unsigned long *a;
a=(unsigned long *)malloc(sizeof(unsigned long));
if (TRUE==InternetGetConnectedState(a,0))
AfxMessageBox("online");
else
AfxMessageBox("offline");
-
June 21st, 2004, 11:31 PM
#4
Broadly speaking, there is no fool proof solution to your question. There was a long running threadDetecting an internet connection , with lots of solutions posted. You can choose one that is appropriate for you.
Even if our suggestions didn't help, please post the answer once you find it. We took the effort to help you, please return it to others.
* While posting code sections please use CODE tags
* Please check the codeguru FAQ and do a little search to see if your question have been answered before.
* Like a post, Rate The Post
* I blog: Network programming, Bible
I do all things thru CHRIST who strengthens me
-
June 22nd, 2004, 07:31 AM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|