home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Collection - Online Library - January 1996 / CKITOS2196.ISO / diskette / gg244090.dsk / unc.dsk / CHAPTER.04 / MATHB_S.C < prev    next >
C/C++ Source or Header  |  1993-10-28  |  2KB  |  55 lines

  1. /******************************************************************************/
  2. /* Module  : mathb_s.c                                                        */
  3. /* Purpose : Perform the necessary setup for the server manager code          */
  4. /*           module mathb_m.c. This module registers manager EPV,             */
  5. /*           selects all protocol sequences available, advertises the server  */
  6. /*           and listens for RPC requests.                                    */
  7. /******************************************************************************/
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <dce/rpc.h>
  12. #include "errchk.h"
  13. #include "mathb.h"
  14.  
  15. #define MAX_CONC_CALLS_PROTSEQ  4       /* Max concurrent calls per protocol. */
  16. #define MAX_CONC_CALLS_TOTAL    8       /* Max concurrent call total.         */
  17. #define ENTRY_NAME "/.:/Servers/MathB"  /* Server entry name.                 */
  18.  
  19. int main ( int argc, char *argv[] )
  20. {
  21.    rpc_binding_vector_t *bv_p;
  22.    unsigned32 status;
  23.  
  24.    /* Register interface/epv associations with RPC runtime.                   */
  25.    printf("Registering server interface with RPC runtime...\n");
  26.    rpc_server_register_if ( mathb_v1_0_s_ifspec, NULL, NULL, &status );
  27.    ERRCHK ( status );
  28.  
  29.    /* Inform RPC runtime to use a supported protocol sequences.               */
  30.    rpc_server_use_protseq("ncadg_ip_udp",MAX_CONC_CALLS_PROTSEQ, &status );
  31.    ERRCHK ( status );
  32.  
  33.    /* Get the binding handle vector from RPC runtime.                         */
  34.    rpc_server_inq_bindings ( &bv_p, &status );
  35.    ERRCHK ( status );
  36.  
  37.    /* Register binding information with endpoint map.                         */
  38.    printf("Registering server endpoints with endpoint mapper (RPCD)...\n");
  39.    rpc_ep_register ( mathb_v1_0_s_ifspec, bv_p, NULL,
  40.                      ( unsigned_char_t * )"Basic math server, version 1.0",
  41.                      &status );
  42.    ERRCHK ( status );
  43.  
  44.    /* Export binding information to the namespace.                            */
  45.    printf("Exporting server bindings into CDS namespace...\n");
  46.    rpc_ns_binding_export ( rpc_c_ns_syntax_dce, ENTRY_NAME,
  47.                            mathb_v1_0_s_ifspec, bv_p, NULL, &status );
  48.    ERRCHK ( status );
  49.  
  50.    /* Listen for service requests.                                            */
  51.    printf ( "Server %s listening...\n", ENTRY_NAME );
  52.    rpc_server_listen ( MAX_CONC_CALLS_TOTAL, &status );
  53.    ERRCHK ( status );
  54. }
  55.