Q: How can I check to see if the STRTCP command has been run? I have a
program that runs at start up that needs TCP/IP. How can I wait until
TCP/IP has started to run it?
A: The Retrieve TCP/IP Attributes (QtocRtvTCPA) API can tell you if
TCP/IP is operational. Carsten Flensburg has written a command that
uses this API to check if TCP/IP is operational.
This RTVTCPSTS command will return one of three values. It will return
O if TCP/IP is operational, N if it is not operational, or E if an
error occurs.
For example, the following is a CL program that checks every second to
see if TCP/IP is operational. Once it’s operational, it could run the
program that needs TCP/IP support:
Pgm
Dcl &TcpSts *Char 1
TryAgain:
RtvTcpSts TcpSts( &TcpSts )
If ( &TcpSts *NE 'O' ) Do
DlyJob Dly(1)
GoTo TryAgain
EndDo
/*-- Run program that needs TCP/IP --*/
EndPgm
You can download the source code for the RtvTcpSts utility from iSeries
Network’s Web site at the following link:
http://www2.systeminetwork.com/noderesources/code/clubtechcode/RtvTcpSts.zip