i'm not asking for the programs, just where to find specific information.
Heres a little info first, the program will run on a server. The network has 50+ pc's and internet access is through 2 isdn lines through a router.
1. How can i programmatically check for an internet connection.
does pinging 127.0.0.1 tell me this and how to incorporate that in a program.
2. if a net connection is not present, i need to telnet into the router and control the maintenance program via a program, then forcing the lines to recconect (if i can control the maintenace program this is simply an option), the maintenance program is console based and uses menus (accessed via corresponding numbers). Totally not sure how to do this.
Surely this has been done before to automate control of the internet connection.
Where can i find information on this.
(I know i asked similar questions before but i have included far more detail this time round.)
1. No, pinging 127.0.0.1 does a local loop and will not tell you if you have internet access. I'm not really sure how you can do this, I'd have to think about it.
2. You can open telnet using popen() and then use the descriptor just like you would a file to send commands and receive text.
I would just ping a well known site like microsoft.com-
> I would just ping a well known site like microsoft.com-
What if that site's down (I know it's unlikely, but it's possible)?
How about if you pinged yourself (your actual internet IP, not some private network IP)
My personal programs pings my ISP.
I'd suggest that you ping microsoft.com (99.999% uptime), and if that site is down, try google.com (high uptime).
For even more accuracy, try more servers (at different physical locations).
Yeah, fair enough i can ping servers.
What i want though is to be able to do this via a program, i don't want to do anything manually, how can i write a program that can ping a server and then report to itself whether or not it has been successful.
I'm sure there are programs out there that check for a net connection in a better way than to ping microsoft.
Thanks for your replies so far guys.
I would suggest looking into SNMP, it is the perfect solution to your problem.
The best set of libraries to use is NET-SNMP ( formaly UCD-SNMP ).
This should allow you to get information from your router that tells you if the internet connection ( interface BRI 0 for instance ) is up, and how many packets it has routed and to what interface.
Good luck with your programming.