Tip

RTCTCPSTS -- Retrieve TCP/IP status

In this tip, Search400.com member Vengoal Chang shares the RTVTCPSTS command source to help you retrieve the TCP/IP status.
 
/*  ===============================================================  */
/*  = Command....... RtvTcpSts                                    =  */
/*  = CPP........... RtvTcpSts RPGLE                              =  */
/*  = Description... Retrieve TCP/IP Status                       =  */
/*  =                                                             =  */
/*  = CrtCmd      Cmd( RtvTcpSts )                                =  */
/*  =             Pgm( RtvTcpSts  )                               =  */
/*  =             SrcFile( YourSourceFile ) Allow(*Ipgm *Bpgm)    =  */
/*  ===============================================================  */
/*  = TCPSTS return value :                                       =  */
/*  =    '0' -- TCP/IP not active                                 =  */
/*  =    '1' -- TCP/IP active                                     =  */
/*  ===============================================================  */
/*  = Date  : 2006/04/24                                          =  */
/*  = Author: Vengoal Chang                                       =  */
/*  ===============================================================  */
             CMD        PROMPT('Retrieve TCP/TP Status')
             PARM       KWD(TCPSTS) TYPE(*CHAR) LEN(1) RTNVAL(*YES) +
                          PROMPT('TCP/IP status')


RTVTCPSTS CPP source(member type CLLE):
/*  ===============================================================  */
/*  = Command RtvTcpSts CPP                                       =  */
/*  =   RtvTcpSts CLLE                                            =  */
/*  =   Paramater notes:                                          =  */
/*  =     TCPSTS  : 1 --> TCP/IP is active                        =  */
/*  =               0 --> TCP/IP is not active                    =  */
/*  ===============================================================  */
/*  = Date  : 2006/04/28                                          =  */
/*  = Author: Vengoal Chang                                       =  */
/*http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/index.htm?   */
/* info/apis/qtocrtvtcpa.htm                                         */
/*  ===============================================================  */ pgm (&TCPSTS)

   dcl &TcpSts *CHAR  1

   dcl &RcvVar *CHAR  140
   dcl &ApiErr *CHAR    8 X'0000000000000000'
   dcl &Format *CHAR    8 'TCPA0100'
   dcl &RcvVarLen *CHAR  4
   dcl &TcpStkSts *CHAR  4
   dcl &TcpStkStsn *dec 10 0

   dcl &MsgId  *CHAR    7
   dcl &MsgDta *CHAR  256
   dcl &MSGF   *CHAR   10
   dcl &MSGFLIB *CHAR  10
   dcl &MSGTXT  *CHAR 256

   MONMSG     MSGID(CPF0000 MCH0000) EXEC(GOTO error)

   chgvar %Bin(&RcvVarLen) 140
   callprc 'QtocRtvTCPA' ( +
                          &RcvVar    +
                          &RcvVarLen +
                          &Format    +
                          &ApiErr)

   ChgVar  &TcpStkSts     %SST(&RcvVar 9 4)
   ChgVar  &TcpStkStsn    %bin(&TcpStkSts)

   If (&TcpStkStsn *NE 1) +
      Chgvar &TcpSts '0'
   Else +
      Chgvar &TcpSts '1'

   Return

/*  ===============================================================  */
/*  = Error routine                                               =  */
/*  ===============================================================  */

Error:

  RcvMsg     MsgType( *Excp )                                         +
             MsgDta( &MsgDta )                                        +
             MsgID( &MsgID )                                          +
             MsgF( &MsgF )                                            +
             MsgFLib( &MsgFLib )
  MonMsg     ( CPF0000 MCH0000 )

SndMsg:

  SndPgmMsg  MsgID( &MsgID )                                          +
             MsgF( &MsgFLib/&MsgF )                                   +
             MsgDta( &MsgDta )                                        +
             MsgType( *Escape )
  MonMsg     ( CPF0000 MCH0000 )

/*  ===============================================================  */
/*  = End of program                                              =  */
/*  ===============================================================  */ endpgm

  
  

Note: In this tip it is VERY important to make sure the name of the API is entered exactly as shown, using upper and lower case in quotes:

 CALLPRC    PRC('QtocRtvTCPA') PARM((&RCVVAR) + 
              (&RCVVARLEN) (&FORMAT) (&APIERR))  

This was first published in May 2006

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.