home *** CD-ROM | disk | FTP | other *** search
- error 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 shows how to customize the client stub so that
- all RPC errors are reported in the return value of the
- remote procedure.
-
-
-
-
- 3. Keywords
-
- error handling, Exit statement, RPC macros, import statement
-
-
-
-
- 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.
- The RPC interface specification imports the error RPC
- specification file to provide the return of any RPC
- error code as the return value of the remote procedure.
-
- error.rpc RPC interface specification for this
- example
-
- error:
-
- Contains the RPC interface specification consisting of
- a client stub with an Exit customization statement.
-
- error_i.rpc error RPC specification
-
- error_i.mk makefile for building the error_i include
- file; the created C file can be ignored
- since the RPC specification consists only
- of a client stub Exit statement.
-
- Note that the RPC Compiler is run only once with this
- RPC specification file as input. Generally, the
- Compiler should be run with the file twice: once for
- the client and once for the server, producing header
- files and RPC code files for each. However, for this
- example the procedure is simplified because the single
- header file produced can be used by both the client and
- the server, and only customization statements are
- included in the file, so the created RPC code file can
- be ignored.
-
-
-
-
- 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 error directory and build the files
- associated with the imported RPC specification file:
-
- make error_i.mk
-
- 2. Change to the client directory (client) and build the
- client:
-
- make client.mk
-
- 3. 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 shows how to add custom code to the client
- stub. It is a simple case which uses the Exit customization
- statement to define instructions to be executed after
- completing the client stub state machine. In this example,
- the return value of the remote procedure call is used to
- return RPC errors.
-
- For more information see the NetWare RPC User's Manual,
- "Customizing Client Stubs," in Chapter 7, and "Error Handling,"
- Chapter 8."