Without understanding the network details, one software on a computer can request a service from another computer on the network through a protocol called Remote Procedure Call (RPC). Sometimes the procedures are done on the same system, making simple function calls but they must be at different address spaces. A procedure call is also called a function call or a subroutine. RPC uses the client-server model. On the client side, the client requests the server for a particular process to be executed which is a remote procedure call, and on the server side, a local procedure call will be made, and it will return the result to the client.
RPC mainly includes the following five elements.
The client
The client stub
The RPC runtime
The server
The server stub
Let's discuss each of these in detail.
The client is a user process that initiates the RPC by requesting the server. The client makes a perfectly normal call sometimes by passing the parameters that invoke a corresponding procedure in the client stub.
The client stub is a piece of code that converts the parameters into a message to be sent to the server. It is used when the client requests the server to do some task. When it receives the request it packs the requirement into a message (builds a message) and asks the RPC runtime to forward it. The packing of procedures is called marshaling. When it receives the result, it will again pack (marshal) the result and send it to the client side.
The RPC runtime is the operating system that handles the transmission between the client and server. It is responsible for making the local and remote OS calls to send or receive the data packets.
It unpacks the call request and makes a call to invoke the suitable procedure in the server. The unpacking of procedures is known as unmarshaling. That is the unpacking of arguments/parameters received from the call packet. When it receives the result it would again pack (marshal) the result and send it to the client side.
The server executes the appropriate procedure and then returns the result to the server stub to forward it to the client side.
Client procedure calls the client stub in a normal way and the client stub builds the message. The procedures in the client stub call the local OS that sends messages to the remote OS. Remote OS gives messages to the server stub. The server stub unpacks parameters and calls the server. The server completes its task and sends the back result to the server stub. The server stub packs it in a message and calls the local OS. The server stub calls the local operating system by packing it in a message. The message is sent to the client OS by the server OS. Stub unpacks the result and returns it to the client.
The illustration below shows how a normal RPC executes.
Free Resources