Open In App

Stub Generation in Distributed System

A stub is a piece of code that translates parameters sent between the client and server during a remote procedure call in distributed computing. An RPC’s main purpose is to allow a local computer (client) to call procedures on another computer remotely (server) because the client and server utilize distinct address spaces. That is the reason parameters used in a function (procedure) call must be translated; otherwise, the values of those parameters would be useless because pointers to parameters in one computer memory would point to different data on the other computer. 

In most cases, stub libraries are installed on both the client and the server. Client stubs transform (marshalling) parameters used in function calls and then reconvert the result returned by the server when the function is completed. On the other side, client arguments are reconverted by server stubs, and results are converted back after function execution.



Stub Generation:

Stubs can be created in two different ways:



To achieve semantic transparency, designers used the concept of stubs to make RPC (Remote Procedure Call) look like LPC (Local Procedure Call). Stubs mask the real RPC implementation from the applications that interface with the underlying RPC system.

Article Tags :