Tech Note: Automatic SLIP or PPP and HTTP restart under Windows NTI run a web server under Windows NT over a SLIP connection and my phone line occasionally drops during the day. I have worked out a way to get my server to restart unattended. This was harder than I thought! I ran across several stumbling blocks:
Here's how it works. I leave this batch file running in a command prompt window. Every 60 seconds it checks to see if my RAS connection is active. If there is no connection, it redials and then restarts the HTTP server. NETCHECK.BATNotes:
Here's the source to the rasup program I wrote. I'm a rusty coder, don't be harsh! The RAS.H include file comes with the Win32 SDK from Microsoft. If you want this program, here it is, as-is with no guarantees. I have only used this on NT 3.5 and NT 3.51 for Intel./* rasup.c Command line utility to see if any Remote Access Service connections are active. Exit status=1 if any are active, otherwise 0. */ #include <windows.h> #include <stdio.h> #include <ras.h> VOID main() { RASCONN rasconnbuf; DWORD cb = sizeof(RASCONN); DWORD ret; DWORD numConn; /* Required to provide buffer size */ rasconnbuf.dwSize = sizeof(rasconnbuf); /* Retrieve info about first active connection (I only have one - change this if you have more) */ ret = RasEnumConnections(&rasconnbuf,&cb, &numConn); if ((numConn == 0) | ret) { printf("No connection, status 0"); exit(0); } else { printf("Active connection, status 1"); exit(1); } } P.S. A thank-you to Robert Reconnu for giving me the net command syntax (I previously used the SC utility from MS VC++), and for verifying that this technique works with a PPP. Last update: December 28, 1995 Technotes |