This chapter covers the following topics:
Remote Procedure Call (RPC) programming allows a program to call procedures outside its current address space. A program can execute a procedure on a remote machine, pass data to it, and retrieve the result. Using RPC, you can write a distributed application that makes use of resources on non-QNX networks. Typically, the host on which the procedure call is executed has resources that aren't available on the calling host.
QNX RPC is based on Sun Microsystems' Open Network Computing (ONC) RPC version 4.
The distribution of computing services imposes a client/server relationship on the two hosts. The host that owns the resource is the server for that resource; the host that makes the procedure call becomes a client of the server when it needs access to the resource.
The RPC system bundles the arguments of the client's procedure into a network packet. The RPC client creates a session by locating the appropriate server and sending the packet to a process on the server that can execute the remote procedure call.
On the server, the RPC system unpacks the arguments; the server then executes the request, packages the result, and returns it to the client. Back on the client side, the RPC system converts the reply into a return value for the procedure call. The program is then reentered as if a local procedure call had completed, thus ending the session.
The format of data sent over network connections (defined by the session layer) makes up the presentation layer. A presentation layer is required in a heterogeneous network to reconcile differences in data representation, which may include:
The presentation layer also provides services to support any packets that contain structures more complex than byte streams.
Programs such as NIS and NFS use the External Data Representation (XDR) protocol at the presentation layer. With XDR, network hosts can exchange structured data independently of any peculiarities of a particular machine.
We've found that John Bloomer's Power Programming with RPC provides a clear description of RPC programming. Topics covered include:
You'll also find an RPC case study that covers load balancing and dynamic scheduling.
Power Programming with RPC also describes programs that use RPC and includes library routines to support these programs. Note that Network Information Service (NIS) and Data Encryption Standard (DES) aren't part of QNX RPC.
In addition to the compiling and linking steps described in the chapter on Socket Programming in QNX, RPC programs must be:
In addition to the requirements specified in the chapter on Socket Programming in QNX, RPC programs must have the portmap daemon running.