home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / n / n001 / 2.ddi / EXAMPLES / ERROR / README
Encoding:
Text File  |  1989-12-11  |  7.4 KB  |  242 lines

  1.                        error Example
  2.  
  3.  
  4.  
  5.  
  6. 1.  Environment
  7.  
  8. This example is designed to be built and executed on a PC
  9. that runs DOS, the Microsoft C Compiler and utilities, and
  10. that uses the NetWare network library.
  11.  
  12.  
  13.  
  14.  
  15. 2.  Overview
  16.  
  17. This example shows how to customize the client stub so that
  18. all RPC errors are reported in the return value of the
  19. remote procedure.
  20.  
  21.  
  22.  
  23.  
  24. 3.  Keywords
  25.  
  26. error handling, Exit statement, RPC macros, import statement
  27.  
  28.  
  29.  
  30.  
  31. 4.  Files
  32.  
  33. Source files for this example reside in the following sub-
  34. directories:
  35.  
  36. server:
  37.  
  38.      Contains code and build procedures for the server part
  39.      of this distributed application.  The server consists
  40.      of the server control procedure, which is provided with
  41.      the product distribution, the dispatcher procedure and
  42.      server stub routines, which are generated by the RPC
  43.      Compiler, and the remote procedures, which are provided
  44.      with this example.
  45.  
  46.      rproc.c       remote procedure application code
  47.  
  48.      server.mk     makefile for building the server
  49.  
  50.      serv_def.h    include file with macro definitions for
  51.                    the server control procedure
  52.  
  53. client:
  54.  
  55.      Contains code and build procedures for the client part
  56.      of this distributed application.  The client consists
  57.      of the client main program and any associated routines,
  58.      which are provided with this example, and the client
  59.      stubs, which are generated by the RPC compiler.
  60.  
  61.      client.c      client application code (main program)
  62.  
  63.      client.mk     makefile for building the client
  64.  
  65. common:
  66.  
  67.      Contains the RPC interface specification used by the
  68.      RPC compiler to create the client and server stubs.
  69.      The RPC interface specification imports the error RPC
  70.      specification file to provide the return of any RPC
  71.      error code as the return value of the remote procedure.
  72.  
  73.      error.rpc     RPC interface specification for this
  74.                    example
  75.  
  76. error:
  77.  
  78.      Contains the RPC interface specification consisting of
  79.      a client stub with an Exit customization statement.
  80.  
  81.      error_i.rpc   error RPC specification
  82.  
  83.      error_i.mk    makefile for building the error_i include
  84.                    file; the created C file can be ignored
  85.                    since the RPC specification consists only
  86.                    of a client stub Exit statement.
  87.  
  88.      Note that the RPC Compiler is run only once with this
  89.      RPC specification file as input.  Generally, the
  90.      Compiler should be run with the file twice: once for
  91.      the client and once for the server, producing header
  92.      files and RPC code files for each.  However, for this
  93.      example the procedure is simplified because the single
  94.      header file produced can be used by both the client and
  95.      the server, and only customization statements are
  96.      included in the file, so the created RPC code file can
  97.      be ignored.
  98.  
  99.  
  100.  
  101.  
  102. 5.  Network Configuration
  103.  
  104. Before you can run this example, you may have to ask your
  105. system administrator to configure your system specifically
  106. for your needs.  The required configuration is described in
  107. the file: ..\..\READSPX
  108.  
  109.  
  110.  
  111.  
  112. 6.  Server Name
  113.  
  114. As distributed, the server for this example will register
  115. under the name "example".  However, it is strongly suggested
  116. that a unique server name be assigned to this example before
  117. it is built.
  118.  
  119. A unique server name will prevent two or more users from
  120. invoking a server process using the same server name.
  121. Choose a server name not likely to be selected by someone
  122. else.  For example, use your user or login name.
  123.  
  124. The server name must be changed in both the client and the
  125. server, and the SAME name must be used.  To change the
  126. server name for the client program, change to the client
  127. directory (client) and edit the file client.c.  Change the
  128. #define Server_Name statement as follows:
  129.  
  130.       #define Server_Name "example"
  131.           is changed to
  132.       #define Server_Name "myname"
  133.  
  134. To change the server name for the server program, change to
  135. the server directory (server) and edit the file serv_def.h,
  136. which contains the define statements for the server control
  137. procedure.  As with the client program, simply change the
  138. #define Server_Name statement.
  139.  
  140.  
  141.  
  142.  
  143. 7.  Building Client & Server
  144.  
  145. Procedures are included for building the example program.
  146. These procedures assume that your environment is set up as
  147. follows:
  148.  
  149.    - The PATH environment variable must specify the location
  150.      of the RPC Compiler executable files.
  151.  
  152.    - The LIB environment variable must specify the location
  153.      of the RPC runtime libraries.
  154.  
  155.    - The INCLUDE environment variable must specify the
  156.      location of the RPC .h include files.
  157.  
  158.    - The PDUDIR environment variable must specify the
  159.      location of the RPC .rpc files.
  160.  
  161.    - The RPCSCP environment variable must specify the
  162.      location of the RPC server control procedures.
  163.  
  164. The PATH, LIB, and INCLUDE environment variables should be
  165. set in your autoexec.bat file by modifying their current
  166. definitions. The PDUDIR and RPCSCP environment variables can
  167. be set in your autoexec.bat file, or in a local .bat file,
  168. or directly with the "set" command.
  169.  
  170. Since a distributed application runs on two machines, you
  171. must install an executable version of the client or server
  172. on another machine.  If the two machines are identical, you
  173. can build both executables (the client and server) on one
  174. machine and then move one of the executables.  However, if
  175. the two machines are not identical, you must follow the
  176. directions on the other machine for running this example and
  177. build one of the executable programs there (note that the
  178. executable filenames may differ across products).
  179.  
  180. Note that with the Microsoft C Compiler and utilities,
  181. numerous warnings will be generated when executing the
  182. makefiles. For example, you may see a "target does not
  183. exist" or "module not in library" warning. These simply mean
  184. that the file the makefile is currently creating does not
  185. yet exist. Generally, all warnings may be ignored.
  186.  
  187. To build the example program, you simply execute the build
  188. procedures in each subdirectory as follows:
  189.  
  190.   1.  Change to the error directory and build the files
  191.       associated with the imported RPC specification file:
  192.  
  193.            make error_i.mk
  194.  
  195.   2.  Change to the client directory (client) and build the
  196.       client:
  197.  
  198.            make client.mk
  199.  
  200.   3.  Change to the server directory (server) and build the
  201.       server:
  202.  
  203.            make server.mk
  204.  
  205.  
  206.  
  207.  
  208.  
  209. 8.  Running the Distributed Application
  210.  
  211. The server program should be started before the client
  212. program is run.
  213.  
  214. To run the example on two machines, proceed as follows:
  215.  
  216.   1.  Change to the server directory (server) on the machine
  217.       running the server and start the server:
  218.  
  219.            server
  220.  
  221.   2.  Change to the client directory (client) on the machine
  222.       running the client and start the client:
  223.  
  224.            client
  225.  
  226.  
  227.  
  228.  
  229.  
  230. 9.  Description
  231.  
  232. This example shows how to add custom code to the client
  233. stub.  It is a simple case which uses the Exit customization
  234. statement to define instructions to be executed after
  235. completing the client stub state machine.  In this example,
  236. the return value of the remote procedure call is used to
  237. return RPC errors.
  238.  
  239. For more information see the NetWare RPC User's Manual,
  240. "Customizing Client Stubs," in Chapter 7, and "Error Handling,"
  241. Chapter 8."
  242.