The most important concept in COM's Local/Remote Transparency is that somehow a server process has an interface pointer that it wants to make available to other processes. The mechanism called marshaling is the means to make this pointer available and to pass arguments from the client's process to the server's process through whatever interprocess communication is established. In all cases, a client calls interface member functions that are located inside a proxy object. The proxy then forwards those calls to a local or remote object as necessary.
An object can use custom marshaling by implementing the IMarshal interface. Through this interface, the object specifies exactly which proxy should be created in the client process (using a CLSID) and provides a marshaling packet for that proxy. The packet contains whatever information is necessary to connect to the remote object—a window handle, a named pipe handle, and so on. The entire sequence of operations involved is neatly encapsulated inside the COM API functions CoMarshalInterface and CoUnmarshalInterface. If an object doesn't want to control its own marshaling, it can simply not implement IMarshal. In this case, COM establishes a connection using standard marshaling, which involves a client-side generic proxy that communicates with a server-side generic stub, which in turn communicates with the local or remote objects.
The generic proxy and stub objects are nothing more than containers, or managers, of marshalers: individual interface proxy and interface stub objects are called facelets and stublets in this book. To support standard marshaling of a custom interface, the interface provider must also provide an implementation of the marshalers for that interface, a process that is nearly automated using the Microsoft-supplied MIDL compiler.
Within the context of standard marshaling, both client and object can perform what is called message filtering, or concurrency management. Message filtering gives an object a single entry point through which it can process, reject, or delay all calls coming to it from other processes. Message filtering gives clients the capability to process pending messages while a synchronous call is being completed as well as the capability to time-out and fail the call when it takes too long. This latter facility involves the standard OLE busy dialog box, provided in the OLE UI Library.
Concurrency management, the busy dialog box, standard marshaling of custom interfaces, and custom marshaling, are all topics demonstrated in this chapter's samples.