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

  1.                        union 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 demonstrates the use of a union. Because the
  18. RPC code places only one of the members from a union into a
  19. Protocol Data Unit (PDU), choice expressions are used in the
  20. RPC declaration to specify the desired member.
  21.  
  22.  
  23.  
  24.  
  25. 3.  Keywords
  26.  
  27. union, choice expression
  28.  
  29.  
  30.  
  31.  
  32. 4.  Files
  33.  
  34. Source files for this example reside in the following sub-
  35. directories:
  36.  
  37. server:
  38.  
  39.      Contains code and build procedures for the server part
  40.      of this distributed application.  The server consists
  41.      of the server control procedure, which is provided with
  42.      the product distribution, the dispatcher procedure and
  43.      server stub routines, which are generated by the RPC
  44.      Compiler, and the remote procedures, which are provided
  45.      with this example.
  46.  
  47.      rproc.c       remote procedure application code
  48.  
  49.      server.mk     makefile for building the server
  50.  
  51.      serv_def.h    include file with macro definitions for
  52.                    the server control procedure
  53.  
  54. client:
  55.  
  56.      Contains code and build procedures for the client part
  57.      of this distributed application.  The client consists
  58.      of the client main program and any associated routines,
  59.      which are provided with this example, and the client
  60.      stubs, which are generated by the RPC compiler.
  61.  
  62.      client.c      client application code (main program)
  63.  
  64.      client.mk     makefile for building the client
  65.  
  66. common:
  67.  
  68.      Contains the RPC interface specification used by the
  69.      RPC compiler to create the client and server stubs.
  70.  
  71.      union.rpc     RPC interface specification for this
  72.                    example
  73.  
  74.  
  75.  
  76.  
  77. 5.  Network Configuration
  78.  
  79. Before you can run this example, you may have to ask your
  80. system administrator to configure your system specifically
  81. for your needs.  The required configuration is described in
  82. the file: ..\..\READSPX
  83.  
  84.  
  85.  
  86.  
  87. 6.  Server Name
  88.  
  89. As distributed, the server for this example will register
  90. under the name "example".  However, it is strongly suggested
  91. that a unique server name be assigned to this example before
  92. it is built.
  93.  
  94. A unique server name will prevent two or more users from
  95. invoking a server process using the same server name.
  96. Choose a server name not likely to be selected by someone
  97. else.  For example, use your user or login name.
  98.  
  99. The server name must be changed in both the client and the
  100. server, and the SAME name must be used.  To change the
  101. server name for the client program, change to the client
  102. directory (client) and edit the file client.c.  Change the
  103. #define Server_Name statement as follows:
  104.  
  105.       #define Server_Name "example"
  106.           is changed to
  107.       #define Server_Name "myname"
  108.  
  109. To change the server name for the server program, change to
  110. the server directory (server) and edit the file serv_def.h,
  111. which contains the define statements for the server control
  112. procedure.  As with the client program, simply change the
  113. #define Server_Name statement.
  114.  
  115.  
  116.  
  117.  
  118. 7.  Building Client & Server
  119.  
  120. Procedures are included for building the example program.
  121. These procedures assume that your environment is set up as
  122. follows:
  123.  
  124.    - The PATH environment variable must specify the location
  125.      of the RPC Compiler executable files.
  126.  
  127.    - The LIB environment variable must specify the location
  128.      of the RPC runtime libraries.
  129.  
  130.    - The INCLUDE environment variable must specify the
  131.      location of the RPC .h include files.
  132.  
  133.    - The PDUDIR environment variable must specify the
  134.      location of the RPC .rpc files.
  135.  
  136.    - The RPCSCP environment variable must specify the
  137.      location of the RPC server control procedures.
  138.  
  139. The PATH, LIB, and INCLUDE environment variables should be
  140. set in your autoexec.bat file by modifying their current
  141. definitions. The PDUDIR and RPCSCP environment variables can
  142. be set in your autoexec.bat file, or in a local .bat file,
  143. or directly with the "set" command.
  144.  
  145. Since a distributed application runs on two machines, you
  146. must install an executable version of the client or server
  147. on another machine.  If the two machines are identical, you
  148. can build both executables (the client and server) on one
  149. machine and then move one of the executables.  However, if
  150. the two machines are not identical, you must follow the
  151. directions on the other machine for running this example and
  152. build one of the executable programs there (note that the
  153. executable filenames may differ across products).
  154.  
  155. Note that with the Microsoft C Compiler and utilities,
  156. numerous warnings will be generated when executing the
  157. makefiles. For example, you may see a "target does not
  158. exist" or "module not in library" warning. These simply mean
  159. that the file the makefile is currently creating does not
  160. yet exist. Generally, all warnings may be ignored.
  161.  
  162. To build the example program, you simply execute the build
  163. procedures in each subdirectory as follows:
  164.  
  165.   1.  Change to the client directory (client) and build the
  166.       client:
  167.  
  168.            make client.mk
  169.  
  170.   2.  Change to the server directory (server) and build the
  171.       server:
  172.  
  173.            make server.mk
  174.  
  175.  
  176.  
  177.  
  178.  
  179. 8.  Running the Distributed Application
  180.  
  181. The server program should be started before the client
  182. program is run.
  183.  
  184. To run the example on two machines, proceed as follows:
  185.  
  186.   1.  Change to the server directory (server) on the machine
  187.       running the server and start the server:
  188.  
  189.            server
  190.  
  191.   2.  Change to the client directory (client) on the machine
  192.       running the client and start the client:
  193.  
  194.            client
  195.  
  196.  
  197.  
  198.  
  199.  
  200. 9.  Description
  201.  
  202. This example demonstrates the use of a union. Because the
  203. RPC code places only one of the members from a union into a
  204. Protocol Data Unit (PDU), choice expressions are used in the
  205. RPC declaration to specify the desired member.
  206.  
  207. Each member of a union must be preceded with a parenthesized
  208. expression that indicates which member is being used.  At
  209. runtime, the union member used is the one whose expression
  210. evaluates to a non-zero value.
  211.  
  212. See "Union Declarations," in Chapter 6 in the NetWare RPC
  213. User's Manual for more information.
  214.