C++ RPC tutorial?

George2 picture George2 · Oct 18, 2009 · Viewed 23.2k times · Source

I want to learn programming C++ (native) on Windows platform for RPC communication. I want to learn both server and client side. I also want to learn some advanced topics, like performance and security.

Any good recommended materials to read?

(BTW: I Googled a few, but all of them either too brief or COM related, I want to learn pure RPC programming without COM. I am using VSTS 2008 with C++.)

Answer

Shay Erlichmen picture Shay Erlichmen · Oct 18, 2009

I would start with the Platform SDK samples on RPC.

  • ASYNCRPC illustrates the structure of an RPC application that uses asynchronous remote procedure calls. It also demonstrates various methods of notification of the call's completion.
  • CLUUID demonstrates use of the client-object UUID to enable a client to select from multiple implementations of a remote procedure.
  • DATA directory contains four programs:
    • DUNION illustrates discriminated (nonencapsulated) unions;
    • INOUT demonstrates [in], [out] parameters;
    • REPAS demonstrates the represent_as attribute;
    • XMIT demonstrates the transmit_as attribute.
  • DYNEPT demonstrates a client application managing its connection to the server through dynamic endpoints.
  • FILEREP directory contains four samples illustrating how developers can write a simple file replication service, a multi-user file replication service, a service supporting security features, and a service using RPC asynchronous pipes.
  • HANDLES directory contains three programs, AUTO, CXHNDL, USRDEF, which demonstrate auto_handle, [context_handle], and generic (user-defined) handles, respectively.
  • HELLO is a client/server implementation of "Hello, world."
  • PICKLE directory contains two programs:
    • PICKLP demonstrates data procedure serialization;
    • PICKLT demonstrates data type serialization; both programs use the [encode] and [decode] attributes.
  • PIPES demonstrates the use of the pipe-type constructor.
  • RPCSVC demonstrates the implementation of a service with RPC.
  • STROUT demonstrates how to allocate memory at a server for a two-dimensional object (an array of pointers) and pass it back to the client as an [out]-only parameter. The client then frees the memory. This technique allows the stub to call the server without knowing in advance how much data will be returned.