Introduction

Remote procedure call (RPC) is based on extending the notion of local procedure call. Called procedure (subroutine) execute in a different address space (commonly on another computer on a shared network). Called procedure is coded as if it were a normal (local) procedure call, without the programmer explicitly coding the details for the remote interaction. In other words, programmer writes essentially the same code whether the subroutine is local to the executing program, or remote.

RPC is used for constructing distributed, client-server based applications. The requesting program is a client, and the service-providing program is the server. It is a synchronous operation requiring the requesting program to be suspended until the results of the remote procedure are returned.

RPC Working

Below steps take place during an RPC

  • Calling procedure invokes a client stub procedure, passing parameters in the usual way. Client stub resides within the client’s own address space. Calling procedure waits for a response to be returned from the remote procedure.
  • The client stub marshalls the parameters into a message. Marshalling includes converting the representation of the parameters into a standard format, and copying each parameter into the message.
  • Client stub passes the message to the transport layer and waits, which sends it to the remote server machine.
  • On the server, the transport layer passes the message to a server stub. Server demarshalls the parameters and calls the desired server routine using the regular procedure call mechanism.
  • Procedure executing on server, upon completion returns to the server stub (via a normal procedure call return).
  • Server stub marshalls the return values into a message, and then hands the message to the transport layer.
  • On the client, the transport layer sends the result message back to the client stub.
  • Client stub demarshalls the return parameters and execution returns to the caller.
Steps in Remote Procedure Call

Client has the knowledge of how to address the remote computer and server application. It also know how to send the message across the network that requests the remote procedure. Similarly, the server includes a runtime program and stub that interface with the remote procedure itself.

Reference

Remote procedure call