Server Examples for IBM i

The CL sample CRT_C_SRV displayed below is provided in the library EXAMPLE of the IBM i installation kit. It demonstrates how to:

  • compile the interface object (for example DEXAMPLE in our sample),

  • compile a server (for example EXAMPLE in our sample) and

  • bind the RPC server and the broker stub (EXA) to both of them

       PGM                                   
       DCL        VAR(&SRCFILE) TYPE(*CHAR) LEN(10) VALUE(QCSRC)
/*-------------------------------------------------------------*/
       MONMSG     MSGID(CZM0613 CPF4102) EXEC(GOTO CMDLBL(ERRXT))

       CRTCMOD    MODULE(DEXAMPLE) +                          
                    SRCFILE(*CURLIB/&SRCFILE) +           
                    OUTPUT(*PRINT) OPTION(*SHOWINC *EXPMAC) + 
                    DBGVIEW(*ALL) SYSIFCOPT(*NOIFSIO)         
       CRTSRVPGM  SRVPGM(DEXAMPLE) MODULE(*CURLIB/DEXAMPLE) + 
                    EXPORT(*ALL) ACTGRP(*CALLER) +            
                    TEXT('C Server Generated Stub') +         
                    BNDSRVPGM(*LIBL/EXPRUNTIME EXA) +         
                    OPTION(*GEN *WARN *NODUPVAR *RSLVREF +
                    *NODUPPROC) DETAIL(*EXTENDED) +           
                    ALWUPD(*YES) ALWLIBUPD(*YES) ALWRINZ(*YES)
                                                          
       CRTCMOD    MODULE(EXAMPLE) +                           
                    SRCFILE(*CURLIB/&SRCFILE) +           
                    OUTPUT(*PRINT) OPTION(*SHOWINC *EXPMAC) + 
                    DBGVIEW(*ALL) SYSIFCOPT(*NOIFSIO)         
                                                          
       CRTSRVPGM  SRVPGM(EXAMPLE) MODULE(*CURLIB/EXAMPLE) +   
                    EXPORT(*ALL) ACTGRP(*CALLER) +            
                    TEXT('C Server Implementation File') +    
                    BNDSRVPGM(*LIBL/EXPRUNTIME EXA) +         
                    OPTION(*GEN *WARN *NODUPVAR *RSLVREF +    
                    *NODUPPROC) DETAIL(*EXTENDED) +           
                    ALWUPD(*YES) ALWLIBUPD(*YES) ALWRINZ(*YES)
/*-----------------------------------------------------------*/
       GOTO       CMDLBL(DONE)                                
ERRXT: SNDPGMMSG  MSG('Compile failed')  
DONE:  ENDPGM