How to check periodically for internet connection using console application? It must work on both Dial-up and LAN. So it would be probably an ping or something like this? Plese if you have some code snippet it will help me. i am absolute beginner in MASM. Thank you. Michal.
what about checking the users IP? if it's not 127.0.0.0 then he's connected right?
Not really true - 127.0.0.1 (.1 not .0) will be your IP if you have the situation where you have, say, no network cards etc. In my case I have a network card and the internet conn, so I get 127.0.0.1 and a 192.168.x.x address for my local and then get the internet addr... ping probably not a bad idea. Search through .asm webrings and sites for some winsock eg. on this OR maybe just try to resolve a known DNS to a IP and if it works you probably got a internet link somewhere (use the resolve winsock command) James
I have got some application yet. It starts checks for conn and close it self. But i need some messageloop or something to do it PERIODICALLY. That is the point. I would sen you my source for you to implement that loop or timer or something because I am not so good to do it. Raguru.
thanks, I'm not a network hero :) why don't you use a timer?
You can use: InternetGetConnectedState its in WININET.DLL ... search info on MSDN
http://www.mvps.org/vbnet/code/reg/activeconnect.htm this is a VB example that works well it queries for a registry key that windows sets when you have a net connection.
You'll probably need to use a combination of InternetGetConnectedState() and ping. The reason for this is that InternetGetConnectedState() only reports information on dialup or LAN connection if the user has set the annoying auto-connect thing properly. If however the user is on dial-up and has set the Always Connected (LAN) option the above function will always return connected when the system isn't, so first check for a connection and then verify with a ping (do a few though because unless you know where the guy is you won't know if he's connected but a servers unreachable, etc.. )
InternetGetConnectedState returns the method by which the computer is connected: INTERNET_CONNECTION_MODEM Local system uses a modem to connect to the Internet. INTERNET_CONNECTION_LAN Local system uses a local area network to connect to the Internet. INTERNET_CONNECTION_PROXY Local system uses a proxy server to connect to the Internet. INTERNET_CONNECTION_MODEM_BUSY Local system's modem is busy with a non-Internet connection. So now it's pretty obvious if it returns LAN connection then you can check something, but you could start accessing the internet immediately anyhow so you don't really need to check anything just connect. See ya, Ben