You are currently on IBM Systems Media’s archival website. Click here to view our new website.

IBM i > TIPS & TECHNIQUES > APPLICATION DEVELOPMENT

A PPP Monitor Utility

Here's a program developed to programmatically obtain the status of a PPP connection

Here's a program developed to programmatically obtain the

I'm passing the name of a work variable (Wk116) that will contain the returned information, the length of the work variable, the name of the configuration profile about which we want information, the PPFR0100 format identifier and a standard error data structure. Another format, PPFR0200, returns more information but isn't needed by my application.

Once the call completes, I move the returned data into a data structure (DSStatus = Wk116;). I check the connection status, which is contained in variable PRCnnSts. A status of 24 indicates the configuration profile has an active connection, a status of 1 indicates an inactive connection and a status of 3 indicates "more information available" (probably a completed connection with data in an output queue). Note that there are several statuses that can be returned--I've included a list in the comments at the end of the procedure source code. Also, note that I'm checking SEMsgID--if this variable that's part of the standard error data structure is not blank, I've encountered an error.

A CLLE procedure that used the CHKPPPSTS procedure is included in CHKPPPC.clle (see Figure 2). It simply uses the Call Procedure (CALLPRC) command to invoke CHKPPPSTS, passing in the name of the configuration profile and receiving the status of the PPP connection.

CALLPRC   PRC(CHKPPPSTS) PARM((&CFGPRF)) RTNVAL(&STATUS)

You create the CHKPPPC program by first creating the CHKPPPSTS and CHKPPPC modules and then binding them together with the Create Program (CRTPGM) command. I've also included a simple test CLLE program (CHKPPPT) in Figure 3 and test command (CHKPPPT) in Figure 4 so you can test the CHKPPPC program.

Recovering Gracefully

I've outlined a simple program (CHKPPPC) to monitor the status of a PPP connection. You would use CHKPPPC after starting the connection (STRTCPPTP) and before attempting a TCP/IP application such as FTP. If you don't receive a status of Active from CHKPPPC, don't perform the application.

You could add more error monitoring, better error reporting and maybe a clever status bar (wowÉthese sound like good enhancements) but, as you can see from this example, PPP status monitoring is simple. Now if you'll excuse me, I think I'll start working on a color-coded status bar. After all, I have a lot of free time--I'm not wrestling with communication errors.

Michael Ryan is a technical editor with IBM Systems Magazine. Michael can be reached at michael@ryantechnology.com.



Advertisement

Advertisement

2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

A PPP Monitor Utility

Here's a program developed to programmatically obtain the status of a PPP connection

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters