Remote Procedure Call

From OSDev Wiki
(Redirected from RPC)
Jump to: navigation, search

What is RPC

Remote Procedure Calls, or RPC's for short, are a means to have certain services executed by some code that lies in an different process (maybe even on a machine located somewhere in the network), instead of being available locally. This is a common practice, employed e.g. by application servers or web applications.

Popular protocols for RPC's are COM+, Corba, or SOAP.

Remote Procedure Calls in a nutshell

An RPC system relies on a compiler that will generate helper code from a high-level interface description (usually IDL or Interface Description Language). The 'client' code that wishes to call a service will actually call a proxy function locally, passing it the arguments for the remote code. The proxy then marshalls (or serializes) the arguments according so that they fit in a flat buffer and send that buffer to the server code (for instance involving a UDP packet or some local message queue) and waits for response.

The server will suddenly receive the marshalled packet and pass it to a stub that will recreate the data (unmarshall) and call the real service procedure, retrieving the results and marshall them back in a message to the client.

 ( client )                                    ( server )
      |                                            ^
      | sayHello("World")                          | serverSayHello("World")
      V                                            |
   +------\     -  -  - <channel>-  -  -  -   \-------+
   | PROXY > ->  iXX mYY Str'W o r l d \0'  -> > STUB |
   +------/     -  -  -  -  - |-  -  -  -     /-------+
                   marshalled message
       ^                                           ^
      /_\                                         /_\
       :                                           :
       :                                           :
       :               |------------|\             :
       :               | .idl file  L_\            :
       +  - compiler - | (describing  | - compiler +
                       |  interface)  |
Personal tools