A Remote Procedure Call (RPC) is a simple and popular paradigm for implementing the client-server model in a distributed system. An RPC is initialized by the requester (client) who sends a message, or request message, to a server to have a certain procedure performed there using the supplied arguments. After completing the procedure, the server sends a reply message or reply back to the client. There are several variations of this method, resulting in multiple (incompatible) RPC protocols.
Interface Description Language #
To make servers accessible to different client machines, a number of standardized RPC systems are necessary. In this way one can make abstraction of platform-specific differences, or one can let programs in several programming languages communicate with each other.
Overview of an RPC system #
The communication between the various parties in an RPC system is preferably as transparent as possible. This means that the developer can write code for procedures that will be executed on another machine, without knowing the details of the communication behind it.
To realize the communication between the client and the server, various RPC systems and programming languages use stubs or proxy objects. When a remote procedure is called, it is handled by the client stub, just as a local procedure would be called in separate code. However, instead of doing the procedure itself, the stub will compose a message and send it to the server. On the server, this message is then received by a server stub, which extracts the message, passes the variables and calls the appropriate function in the server. The result is then given back to the server stub, which in turn sends it back to the client stub. This unpacks the message and passes the result in the same way as if the procedure had been performed locally. Stubs are usually generated from the IDL description of the interface.
Ethereum #
Ethereum makes use of a so called JSON RPC, which is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments. It uses JSON (RFC 4627) as data format.