Remote Procedure Calls (RPC)
IPC part of distributed system can often be conveniently handled by message-passing model.
It doesn't offer a uniform panacea for all the needs.RPC emerged as a result of this. It can be
said as the special case of message-passing model.
Remote Procedure Call (RPC) is an inter process communication technique to allow client
and server software to communicate. RPC is a powerful technique for constructing
distributed, client-server based applications. It is based on extending the notion of
conventional or local procedure calling, so that the called procedure need not exist in the
same address space as the calling procedure. The two processes may be on the same system,
or they may be on different systems with a network connecting them. By using RPC,
programmers of distributed applications avoid the details of the interface with the network.
It has become widely accepted because of the following features:
Simple call syntax and similarity to local procedure calls.
It specifies a well defined interface and this property supports compile-time
type checking and automated interface generation.
Its ease of use, efficiency and generality.
It can be used as an IPC mechanism between
Processes on different machines and also between different processes
on the same machine.
Transparency of RPC:
A transparent RPC is one in which the local and remote procedure calls are
Types of transparencies:
Syntactic transparency: A remote procedure call should have
exactly the same syntax as a local procedure call.
Semantic transparency: The semantics of a remote procedure call
are identical to those of a local procedure call.
Syntactic transparency is not an issue but semantic transparency is difficult.
Remote procedure calls vs. Local procedure calls:
Difference between remote procedure calls and local procedure calls:
1. Unlike local procedure calls, with remote procedure calls,
i. Disjoint Address Space
ii. Absence of shared memory.
iii. Meaningless making call by reference, using addresses in arguments and
2. RPC’s are more vulnerable to failure because of:
i. Possibility of processor crashes or
ii. communication problems of a network.
3. RPC’s are much more time consuming than LPC’s due to the involvement of
Due to these reasons, total semantic transparency is impossible.
It is similar to commonly used procedure call model. It works in the following manner:
For making a procedure call, the caller places arguments to the procedure in
some well specified location.
Control is then transferred to the sequence of instructions that constitutes the
body of the procedure.
The procedure body is executed in a newly created execution environment
that includes copies of the arguments given in the calling instruction.
After the procedure execution is over, control returns to the calling point,
returning a result.
The RPC enables a call to be made to a procedure that does not reside in the address space of
the calling process. Since the caller and the callee processes have disjoint address space, the
remote procedure has no access to data and variables of the caller’s environment. RPC
facility uses a message-passing scheme for information exchange between the caller and the
callee processes. On arrival of request message, the server processes the following tasks:
extracts the procedure’s parameters,
computes the result,
sends a reply message, and
then awaits the next call message.
Implementing RPC Mechanism:
To achieve semantic transparency, implementation of RPC mechanism is based on the
concepts of stubs.
Stubs: It Provide a normal / local procedure call abstraction by concealing the
underlying RPC mechanism. A separate stub procedure is associated with both the
client and server processes. To hide the underlying communication network, RPC
communication package known as RPC Runtime is used on both the sides.
Thus implementation of RPC involves the five elements of program:
o Client Stub
o RPC Runtime
o Server stub
The client, the client stub, and one instance of RPCRuntime execute on the client
The server, the server stub, and one instance of RPCRuntime execute on the
As far as the client is concerned, remote services are accessed by the user by
making ordinary LPC
It is responsible for the following two tasks:
On receipt of a call request from the client,
o It packs specifications of the target procedure and the arguments
into a message and asks the local RPC Runtime to send it to the
On receipt of the result of procedure execution, it unpacks the result and
passes it to the client.
It handles transmission of messages across the network between Client and the server
It is responsible for Retransmission, Acknowledgement, Routing and
It is responsible for the following two tasks:
On receipt of a call request message from the local RPCRuntime, it unpacks it
and makes a perfectly normal call to invoke the appropriate procedure in the
On receipt of the result of procedure execution from the server, it unpacks the
result into a message and then asks the local RPCRuntime to send it to the
Some special types or RPCs:
Callback RPC: It facilitates a peer-to-Peer paradigm among participating processes. It
allows a process to be both a client and a server. Remotely processed interactive
Broadcast RPC: A client’s request is broadcast on the network and is processed by all
servers that have the procedure for processing that request.
Batch-mode RPC: Batch-mode RPC is used to queue separate RPC requests in a
transmission buffer on the client side and then send them over the network in one
batch to the server.
RPC, a Practical Example:
The following steps have to be taken to establish a RPC.
Decide what are methods that you’ll be RPC.
Generate UUID (Universal Unique IDentifier)
o uuidgen /i /o”E:Interface.idl”
Developing IDL file.
Developing Application Configuration File (ACF)
Implementing the RPC (whether in server or standalone application)
Generating stub file (VS or MIDL)
Developing the client side
o Adding client stub file amd generated header file.
Combines an object UUID, a protocol sequence, a network address, an
endpoint and other network options into a string representation of a
Creates a server binding handle from a string representation of a
o Call RPC using RpcTryExcept
Developing the server side
Tells the RPC run-time library to use the specified protocol sequence
combined with the specified endpoint for receiving remote procedure
Registers an interface with the RPC run-time library
A server calls RpcServerListen when the server is ready to process
remote procedure calls.