home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / r / rem-file.zip / remote_file / r_server.c < prev    next >
C/C++ Source or Header  |  1992-06-03  |  3KB  |  63 lines

  1. /* FILE NAME: r_server.c */
  2. #include <stdio.h>
  3. #include "remote_file.h"               /* header created by the idl compiler */
  4. #include "check_status.h"              /* contains the CHECK_STATUS macro    */
  5. main ()
  6. {
  7.    unsigned32             status;          /* error status (nbase.h)         */
  8.    rpc_binding_vector_t   *binding_vector; /* binding handle list (rpcbase.h)*/
  9.  
  10.    rpc_server_register_if(       /* register interface with the RPC runtime */
  11.       remote_file_v1_0_s_ifspec, /* handle for interface specification      */
  12.       NULL,                     
  13.       NULL,                     
  14.       &status                   /* error status */
  15.    );
  16.    CHECK_STATUS(status, "Can't register interface\n", ABORT);
  17.  
  18.    rpc_server_use_all_protseqs(            /* establish protocol sequences  */
  19.       rpc_c_protseq_max_reqs_default,      /* queue length for remote calls */
  20.       &status
  21.    );
  22.    CHECK_STATUS(status, "Can't establish protocol sequences\n", ABORT);
  23.  
  24.    rpc_server_inq_bindings(     /* get set of this server's binding handles */
  25.       &binding_vector,
  26.       &status
  27.    ); 
  28.    CHECK_STATUS(status, "Can't get binding handles\n", ABORT);
  29.  
  30.    rpc_ep_register(                  /* add endpoint to local endpoint map  */
  31.       remote_file_v1_0_s_ifspec,     /* handle for interface specification  */
  32.       binding_vector,                /* vector of server binding handles    */
  33.       NULL,                          /* no object UUIDs to register         */
  34.       (unsigned_char_t *)"remote_file server", /* annotation (not required) */
  35.       &status 
  36.    );
  37.    CHECK_STATUS(status, "Can't add endpoints to local endpoint map:", ABORT);
  38.  
  39.    puts("Listening for remote procedure calls...");
  40.    TRY
  41.       rpc_server_listen(                         /* listen for remote calls */
  42.          rpc_c_listen_max_calls_default,         /* number of threads       */
  43.          &status
  44.       );
  45.       CHECK_STATUS(status, "rpc listen failed:", RESUME);
  46.    FINALLY
  47.       puts("Removing endpoints from local endpoint map.");
  48.       rpc_ep_unregister(        /* remove endpoints from local endpoint map */
  49.          remote_file_v1_0_s_ifspec,   /* handle for interface specificaiton */
  50.          binding_vector,              /* vector of server binding handles   */
  51.          NULL,                        /* no object UUIDs to unregister      */
  52.          &status 
  53.       );
  54.       CHECK_STATUS(status,"Can't remove endpoints from endpoint map:", RESUME);
  55.  
  56.       rpc_binding_vector_free(               /* free set of binding handles */
  57.          &binding_vector,
  58.          &status
  59.       ); 
  60.       CHECK_STATUS(status, "Can't free binding handles and vector\n", ABORT);
  61.    ENDTRY
  62. }
  63.