Server Application RPC API Calls

For most distributed applications, you should write your server application to call the RPC functions in the following sequence:

  1. Specify the protocol sequence(s). Call one of the following RPC functions: RpcServerUseProtseq, RpcServerUseAllProtseqs, RpcServerUseProtseqIf, RpcServerUseAllProtseqsIf, and RpcServerUseProtseqEp

    or the extended versions, which allow you to specify a policy for allocation of dynamic ports and allow allow multi-homed machines to selectively bind to Network Interface Cards (NICS):

    RpcServerUseProtseqEx, RpcServerUseAllProtseqsEx, RpcServerUseProtseqIfEx, RpcServerUseAllProtseqsIfEx, and RpcServerUseProtseqEpEx.

  2. Call RpcServerInqBindings to obtain a vector containing all of the server's binding handles. You will use this binding vector for subsequent calls to RpcEpRegister, RpcEpRegisterNoReplace, and RpcNsBindingExport.
  3. When you use dynamic endpoints, add the endpoints associated with the server to the endpoint-map database. Call RpcEpRegister or RpcEpRegisterNoReplace register the binding handles with the endpoint-mapping service.

    During implementation and debugging, you can use string bindings to communicate binding information to clients. This allows you to establish a client-server relationship without using the endpoint-map database or name-service database. To establish such a relationship, use RpcBindingToStringBinding to convert one or more binding handles in the binding-handle vector to a string binding and provide the string binding to the client.

  4. Call RpcBindingReset on each of the dynamic bindings in the binding vecto to remove the dynamic endpoints from the bindings. Then export the binding vector to the name-service database. Call Page: 1
    RpcNsBindingExport to place the binding handles in the name-service database for access by any client.
  5. Clean up data structures. Call the RPC function RpcBindingVectorFree. to free the vector of server binding handles.
  6. Register the interface with the RPC run-time library. Call RpcServerRegisterIfEx or RpcServerRegisterIf. This is a required call.
  7. Listen for clients. Call RpcServerListen or RpcMgmtWaitServerListen. RpcServerListen to begin receiving remote procedure call requests. This is a required call.

When the server application is no longer actively serving clients, you usually instruct it to call RPC functions in the following sequence:

  1. Stop listening for clients. Call the RPC function RpcMgmtStopServerListening.

    If the server application is merely pausing, this is the only call that needs to be made. If the application is terminating:

  2. Remove the interface. Call the RPC function RpcServerUnregisterIf.
  3. Remove endpoint-map database entries. Call the RPC function RpcEpUnregister.
  4. Remove the name-service entry. Call RpcNsBindingUnexport

See Also

Specifying the Protocol Sequence, Registering the Endpoint, Exporting to the RPC Name-Service Database, Registering the Interface.