OSF DCE Application Development Guide--Core Components

Developing a Simple RPC Application
In this example, after each call to an RPC runtime routine, the client program calls the
application-specific ERROR_CHECK macro. If the status from the RPC runtime
routine is not error_status_ok, dce_error_inq_text( ) is called and the error message is
printed.
As specified in the greet.idl interface definition, the greet application uses explicit
handles. The client therefore passes a binding handle of type handle_t as the first
parameter of the greet procedure. At runtime, when the client makes its first remote
procedure call, the handle is only partially bound because the client does not know the
particular endpoint on which the server is listening; for delivery of its requests to the
server endpoint, the client depends on the endpoint mapping service of the dced process
on the server host.
11.5 Writing the Server Code
The following subsections describe the server program for the greet application. The
greet_server program takes one argument and is invoked as follows:
greet_server CDS_pathname
The greet_server program uses the input argument to establish an entry for itself in the
DCE CDS namespace.
The greet server program has two user-written modules:
The greet_server.c module contains the server main function and performs the
initialization and registration required to export the greet interface.
The greet_manager.c module contains the code that actually implements the greet
operation.
11.5.1 The greet_server.c Source Code
Most applications should use the DCE convenience routines for server initialization
routines (routines that begin with dce_server_) to prepare servers to listen for remote
procedure calls. These routines are simple to use, prepare a server so that dced can
manage it, and they allow enough flexibility to do most typical initializations. However,
for detailed control, applications can also use the lower-level RPC API to do server
initialization. In this chapter, we describe how to use the RPC API for server
initialization.
In this section, the greet_server.c module is described and shown in successive pieces.
124245 Tandem Computers Incorporated 11 19