home *** CD-ROM | disk | FTP | other *** search
- pointer Example
-
-
-
-
- 1. Environment
-
- This example is designed to be built and executed on a PC
- that runs DOS, the Microsoft C Compiler and utilities, and
- that uses the NetWare network library.
-
-
-
-
- 2. Overview
-
- This example is a simple demonstration of passing a pointer
- variable as a parameter to a remote procedure.
-
-
-
-
- 3. Keywords
-
- pointer, termination expression, typedef, memory management
-
-
-
-
- 4. Files
-
- Source files for this example reside in the following sub-
- directories:
-
- server:
-
- Contains code and build procedures for the server part
- of this distributed application. The server consists
- of the server control procedure, which is provided with
- the product distribution, the dispatcher procedure and
- server stub routines, which are generated by the RPC
- Compiler, and the remote procedures, which are provided
- with this example.
-
- rproc.c remote procedure application code
-
- server.mk makefile for building the server
-
- serv_def.h include file with macro definitions for
- the server control procedure
-
- client:
-
- Contains code and build procedures for the client part
- of this distributed application. The client consists
- of the client main program and any associated routines,
- which are provided with this example, and the client
- stubs, which are generated by the RPC compiler.
-
- client.c client application code (main program)
-
- client.mk makefile for building the client
-
- common:
-
- Contains the RPC interface specification used by the
- RPC compiler to create the client and server stubs.
-
- pointer.rpc RPC interface specification for this
- example
-
-
-
-
- 5. Network Configuration
-
- Before you can run this example, you may have to ask your
- system administrator to configure your system specifically
- for your needs. The required configuration is described in
- the file: ..\..\READSPX
-
-
-
-
- 6. Server Name
-
- As distributed, the server for this example will register
- under the name "example". However, it is strongly suggested
- that a unique server name be assigned to this example before
- it is built.
-
- A unique server name will prevent two or more users from
- invoking a server process using the same server name.
- Choose a server name not likely to be selected by someone
- else. For example, use your user or login name.
-
- The server name must be changed in both the client and the
- server, and the SAME name must be used. To change the
- server name for the client program, change to the client
- directory (client) and edit the file client.c. Change the
- #define Server_Name statement as follows:
-
- #define Server_Name "example"
- is changed to
- #define Server_Name "myname"
-
- To change the server name for the server program, change to
- the server directory (server) and edit the file serv_def.h,
- which contains the define statements for the server control
- procedure. As with the client program, simply change the
- #define Server_Name statement.
-
-
-
-
- 7. Building Client & Server
-
- Procedures are included for building the example program.
- These procedures assume that your environment is set up as
- follows:
-
- - The PATH environment variable must specify the location
- of the RPC Compiler executable files.
-
- - The LIB environment variable must specify the location
- of the RPC runtime libraries.
-
- - The INCLUDE environment variable must specify the
- location of the RPC .h include files.
-
- - The PDUDIR environment variable must specify the
- location of the RPC .rpc files.
-
- - The RPCSCP environment variable must specify the
- location of the RPC server control procedures.
-
- The PATH, LIB, and INCLUDE environment variables should be
- set in your autoexec.bat file by modifying their current
- definitions. The PDUDIR and RPCSCP environment variables can
- be set in your autoexec.bat file, or in a local .bat file,
- or directly with the "set" command.
-
- Since a distributed application runs on two machines, you
- must install an executable version of the client or server
- on another machine. If the two machines are identical, you
- can build both executables (the client and server) on one
- machine and then move one of the executables. However, if
- the two machines are not identical, you must follow the
- directions on the other machine for running this example and
- build one of the executable programs there (note that the
- executable filenames may differ across products).
-
- Note that with the Microsoft C Compiler and utilities,
- numerous warnings will be generated when executing the
- makefiles. For example, you may see a "target does not
- exist" or "module not in library" warning. These simply mean
- that the file the makefile is currently creating does not
- yet exist. Generally, all warnings may be ignored.
-
- To build the example program, you simply execute the build
- procedures in each subdirectory as follows:
-
- 1. Change to the client directory (client) and build the
- client:
-
- make client.mk
-
- 2. Change to the server directory (server) and build the
- server:
-
- make server.mk
-
-
-
-
-
- 8. Running the Distributed Application
-
- The server program should be started before the client
- program is run.
-
- To run the example on two machines, proceed as follows:
-
- 1. Change to the server directory (server) on the machine
- running the server and start the server:
-
- server
-
- 2. Change to the client directory (client) on the machine
- running the client and start the client:
-
- client
-
-
-
-
-
- 9. Description
-
- This example demonstrates passing a character string to a
- remote procedure. The character string has an associated
- termination expression, so characters up to and including
- the null character are passed. A pointer to the string is
- passed as an input parameter. The address of a pointer to
- the string is passed as an output parameter, and the remote
- procedure dynamically allocates space for the string.
-
- The client stub will allocate memory for the returned
- string, and the client should free this memory when the
- string is no longer needed. The server should arrange to
- free the memory it allocated dynamically. The freemem
- example shows how to handle dynamically allocated memory.
-
- For more information, see "Pointer Declarations," in
- Chapter 6, in the NetWare RPC User's Manual.