Determine when I am connected on LAN
-
Please, If someone know how can I determine within my application if network cable is unplugged ? Thank you ! Alan
-
Please, If someone know how can I determine within my application if network cable is unplugged ? Thank you ! Alan
-
Please, If someone know how can I determine within my application if network cable is unplugged ? Thank you ! Alan
check the ip interfaces.. if the network cable is unplugged, there wont be any ip interface for the adapter(on win2k and later). Don't try it, just do it! ;-)
-
See
InternetGetConnectedState()
. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.comi think this wont solve all problems.. if the lan isnt used for internet, i suppose this wont work! Don't try it, just do it! ;-)
-
check the ip interfaces.. if the network cable is unplugged, there wont be any ip interface for the adapter(on win2k and later). Don't try it, just do it! ;-)
Ok, thank you, sound's great, but since I'm almost new in this world, can you please give me some line of code ? Tnx
-
Ok, thank you, sound's great, but since I'm almost new in this world, can you please give me some line of code ? Tnx
Maybe you use this code, its working for all known cases. ok, its working at least for all my cases bye mario 1) InternetCheckConnection ( Checks for Google ) 2) InternetAttemptConnect ( Windows Function ) 3) IsModem Connected ( Modem Connection ) 4) gethostbyname ( Google ) 5) InternetGetConnectedState ( LAN ) 6) Dont check for Internetconnection // Check if Online BOOL WINAPI IsADSLConnected() { LPDWORD lpdwFlags=0; DWORD dwReserved=0; RASCONN rc; rc.dwSize = sizeof(rc); DWORD numConns=0; DWORD size=0; DWORD res; do { switch(g_m_ConMode) { case 0: try { g_IsConnected=InternetCheckConnection("http://www.google.com",FLAG_ICC_FORCE_CONNECTION ,0); } catch(...) { g_m_ConMode = 4; } break; case 1: res = InternetAttemptConnect(0); if(res == ERROR_SUCCESS) g_IsConnected = 1; else g_IsConnected = 0; break; case 2: // Enumerate the connections. res = RasEnumConnections(&rc, &size, &numConns); if (numConns > 0 || InternetGetConnectedState(lpdwFlags,dwReserved)) g_IsConnected = 1; else g_IsConnected = 0; break; case 3: if (gethostbyname ("www.google.com")) g_IsConnected = 1; else g_IsConnected = 0; break; case 4: g_IsConnected = 0; if (::InternetGetConnectedState (&dwReserved, 0)) { if ((dwReserved & INTERNET_CONNECTION_LAN) || (dwReserved & INTERNET_CONNECTION_MODEM) || (dwReserved & INTERNET_CONNECTION_PROXY)) { g_IsConnected = 1; } } break; case 5: g_IsConnected = 0; break; } Sleep(2500); } while(1); }
-
Ok, thank you, sound's great, but since I'm almost new in this world, can you please give me some line of code ? Tnx
Can you help me also with next one more thing: if I detect that I'm connected on my LAN, how can I measure speed between my pc and server (I know only name of that server). Tnx
-
Can you help me also with next one more thing: if I detect that I'm connected on my LAN, how can I measure speed between my pc and server (I know only name of that server). Tnx