![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Networking Support General Networking Support Forum |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Mar 2007
Posts: 10
OS: fedora5
|
regarding serverdown
hi all
this is the code to know wether the net on or off #include <stdio.h> #include <unistd.h> #include <netdb.h> #include <gtk/gtk.h> #include <stdlib.h> #include <string.h> int can_resolve_host (const char *host) { struct hostent *h = NULL; h = gethostbyname (host); if (h == NULL) { return -1; } else { return 0; } } int netstate() { FILE* FD; char buf[256] = {0}; char* linkstatus = NULL; FD = popen ("/sbin/mii-tool", "r"); if (FD) { fgets (buf, sizeof (buf), FD); buf[strlen(buf) - 1] = '\0'; linkstatus = strstr (buf, "ok"); } pclose (FD); if ((linkstatus) && (0 == strcmp (linkstatus, "ok"))) { if (can_resolve_host ("axillsearch.com") == -1) { printf ("Failed to reach axillsearch.com\n"); } else { printf ("Successfully reached axillsearch.com\n"); } } else fprintf (stderr, "%s(): Network connectivity not available \n", __func__); printf ("U r net is down \n"); return -1; } int main (int argc, char *argv[]) { int i; i=gtk_timeout_add(8000, (GtkFunction) netstate, NULL); gtk_main (); return 0; } save it has one.c and compile gcc one.c -o one `pkg-config gtk+-2.0 --cflags --libs` it is working successfully when 1.net deactivate or activate 2.cable unplugged or plugged but it is not working when the server is down how can i do when the server is down when the serveris down(main servers) it has to show the message like "U r net is down \n" if any help cheers |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Manager, Networking Forums
Join Date: Sep 2002
Location: S.E. Pennsylvania, US
Posts: 41,654
OS: Windows 7, XP-Pro, Vista, Linux
Blog Entries: 1
|
And the point of the post would be?
__________________
If TSF has helped you, Tell us about it! or Donate to help keep the site up! Microsoft MVP - Windows Desktop Experience |
|
|
|
![]() |
| Thread Tools | |
|
|