Remote Procedure Call

From OSDev.wiki
Revision as of 10:16, 11 January 2007 by Combuster (talk | contribs) (ported RPC page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to 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

A RPC system relies on a compiler that will generate helper code from a high-level interface description (usually IDL, "Interface Description Language"). The 'client' code that wish 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.

On its side, the server suddenly receive the marshalled packet and will pass it to a stub that will re-create the data (unmarshall) and call the real service procedure, getting back 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)  |
                      +--------------+