is there any way to have a console win32 program check for current internet acess?
is there any way to have a console win32 program check for current internet acess?
Last edited by canine; 09-23-2001 at 09:45 AM.
I'm not sure, but you could always use an unreliable method: try to connect to a major website such as yahoo.com on it's port 80 (HTTP port) if it works, then you're online, so just disconnect from the port and continue merrily along with your program. If it fails then you're (most likely) not connected (I say most likely because the site could be down. Try connecting to two or three servers if the first won't work.) and you should halt the program and ask for the user to connect to the internet, then check those servers again to make sure.
hope that helps!
sorry, but do u have any site that would tell me how to do that? i would have no idea where to start...
just look up "winsock code c" or something similar on google.
Check out this link! Best tutorial I have ever found along the lines of WinSock. It's for C++ but I have been easily able to change the few small things that are pure C++ into C code so then I can understand it more easily. If you need help in doing likewise just give me a PM and I'd be glad to help you out
http://www.hal-pc.org/~johnnie2/winsock.html
cerion
Use the code Luke.
Using the methos of checking for an internet connection by connecting through a site in port 80 may be a problem. Firewalls could be unreliable and also port 80 may be in use by something other than an internet connection. I would suggest simply asking if they will allow you yo connect to the internet and if they say yes than they are bound to be connected. Otherwise if the say no they probably aren't. you could also have an options setting to record if they are using a dial-up or a lan connection to the internet because if it was dial-up you could open the dial-up connection but if lan just access it without any problems.