For users new to RPC, this section will provide a broad overview of what it is, and of the different components involved in the process. If you're already familiar with how RPC works, feel free to skip this section.Speaking generically, RPC is a toolkit designed for distributed computing. It provides a framework for executing procedures on one system from another, completely independent system in a secure, reliable, and efficient manner.The best way to understand the RPC programming model is perhaps by compar-ing it to the "regular" programming model, in which procedures, or functions, are invoked on the same system or within the same program. Figure 6.1 and Figure 6.2 illustrate the difference.
Figure 6.1. A local function call.
Figure 6.2. A remote function call.
As you can see from Figure 6.2, the RPC programming model is built completely around a client-server framework and consists of the following components:
An API to handle procedure registration and execution on the server, and procedure invocation on the client
A set of rules for encoding and decoding RPC requests and responses
A network transmission layer to actually perform communication between the client and server, and carry data packets back and forth (HTTP works well here, although other protocols may also be used)
Here's how it all comes together:
A remote procedure is invoked by an RPC client.
The procedure call, together with arguments (if any), is encoded into a request packet suitable for transmission across a network.
The request packet is transmitted to the RPC server.
The RPC server receives the packet and extracts the procedure name and arguments (if available) from it.
The RPC server invokes the named procedure on the server and obtains a return value from it.
The return value is encoded into a response packet.
The response packet is transmitted back to the RPC client.
The RPC client receives the response packet, decodes it, and extracts the procedure's return value from it. This result value can then be used by the client within a script or program.
Obviously, this is a simplified version of the RPC programming modelit does not address issues such as procedure registration, state maintenance, error handling, or security. However, it should be sufficient to explain the fundamental principles of the programming model, and lay the foundation for the material in subsequent sections.If you want to learn more about RPC, drop by this book's companion web site, which contains links to web sites with more information on the topic.