home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <winsock.h>
-
-
- void disp_help()
-
- {
-
- printf("\nKeep alive program V 1.0 by L. Kahn (C) 1994\n");
- printf("_______________________________________________\n\n");
- printf("This program keeps a connection alive by \n");
- printf("continually pinging a specific host name\n");
- printf("every XXX seconds\n");
-
- printf("Syntax: keepalive hostname timeout\n");
- printf("WHERE: hostname is the name or ip address of a host.\n");
- printf(" and timeout is in seconds.\n");
-
- }
-
-
- void main(argc,argv)
-
- int argc;
- char **argv;
-
- {
-
-
- char command[250];
- int rv = 0;
- int timeout = 0;
-
- if (argc != 3)
- disp_help();
-
- else
- {
- /* ok assume second arg is host name */
-
- timeout = atoi(argv[2]) * 1000;
- strcpy(command,"ping ");
- strcat(command,argv[1]);
-
- while (TRUE)
- {
- rv = system(command);
- printf("\nSleeping for %d seconds.\n",timeout/1000);
- Sleep(timeout);
- }
-
- printf("\n");
- fflush(stdout);
-
- } /* end of else */
-
- } /* end of main */
-
-
-