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

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