Share via


RPC runtime internal

No doubt, RPC is a great technology in 90's. Until now, many framework and technologies still build on the RPC layer.

In 1992, MS RPC runtime was designed and implemented, it is complex and become more and more robust.

To review this technology, here are a few samples.

Server Startup
====================
main(...)
{
    RpcServerRegsiterIf(...);
    RpcServerUseProtseqEp(...);
    RpcServerUseProtseq(...);
    RpcServerListen(...);
}

Client Call
====================
main(...)
{
    RpcStringBindingCompose(...);
    RpcBindingFromStringBinding(...);
    RpcTryExcept
    {
       RPC_STUB_CALL(...);
    } RpcExcept(...) {}
    RpcStringFree(...);
    RpcBindingFree(...);
}

A client stub
====================
ClientStub(RPC_BINDING_HANDLE BindingHandle,...)
{
    RPC_MESSAGE RpcMessage;
    RpcMessage.Handle = BindingHandle;
    RpcMessage.BufferLength = ...;
    I_RpcGetBuffer(&RpcMessage); //allocate buffer on client side
    I_RpcSendReceive(&RpcMessage); //make the call
    I_RpcFreeBuffer(&RpcMessage); //release buffer
    return(...);
}

A server stub
====================
ServerStub(RPC_MESSAGE* RpcMessage)
{
    //unmarshall the arguments from the buffer
    //calculate the buffer size
    RpcMessage->BufferLength = ...;
    I_RpcGetBuffer(&RpcMessage);
    //marshall the results into the buffer
}

Under the hood, there are LPC, OSF DCE, NamedPipe...