Remote Procedure Call (RPC)

This section provides comprehensive documentation for the Microsoft Remote Procedure Call (RPC) service. RPC allows a program to execute a procedure (subroutine) in a different address space, which is typically on another computer on a shared network without the programmer explicitly coding the details of this remote interaction.

Overview

Remote Procedure Call (RPC) is a technology that enables a client program to call a server program without knowing that the call is remote. RPC handles the complexities of interprocess communication, including message marshalling and unmarshalling, data conversion, and network transport details. This abstraction simplifies the development of distributed applications.

Key Concepts

  • Client: The program that initiates the RPC call.
  • Server: The program that hosts the remote procedure.
  • Interface: A definition of the procedures that can be called remotely, including their parameters and return types. Defined using the Microsoft Interface Definition Language (MIDL).
  • Stub: Code generated by MIDL that acts as a proxy for the remote procedure on the client side (client stub) and the server side (server stub).
  • Runtime Library: Provides the underlying communication mechanisms and manages the RPC process.
  • Binding: The process of establishing a connection between a client and a server.
Tip: Understanding the MIDL language is crucial for defining your RPC interfaces effectively.

Core Components

MIDL (Microsoft Interface Definition Language)

MIDL is used to define the interfaces between clients and servers. It describes the data types and functions that will be transmitted across the network. The MIDL compiler generates C/C++ header files and stub code from MIDL source files (.idl).

// Example .idl file snippet
interface my_interface
{
    long Add(long a, long b);
    void SayHello([in, string] const unsigned char *pszName);
}

RPC Runtime

The RPC runtime library handles the details of network communication, data marshalling (converting data structures into a transmittable format), and unmarshalling (reconstructing data structures). It supports various transport protocols like TCP/IP and named pipes.

Common RPC Scenarios

  • Service Discovery: Clients find available RPC services on the network.
  • Data Serialization: Complex data structures are prepared for transmission.
  • Error Handling: Mechanisms for reporting and managing errors during remote calls.

API Reference

Below are links to specific API categories within Windows RPC programming:

Tutorials and Samples

Explore these resources to get started with RPC development: