The Difference Between COM and DCOM


Most of the differences between COM and DCOM applications are hidden from the developer. The client and server program can be written

identically, regardless of where the programs are running. This concept is known as Local/Remote Transparency. This makes your job as a

programmer much more consistent.

Of course, there are some real differences in how distributed and local COM work internally. Local communications can be accomplished many

ways, including simple Windows messages. Connecting to a remote computer requires a whole new layer of objects and network traffic.

Despite these rather large differences, there are only a few things in your program you'll need to change.

Like all COM communication, everything starts when the client requests an interface from a server. In DCOM, the client calls

CoCreateInstanceEx(), passing in a description of the server computer and requesting a class identifier (CLSID) and Interface. This request

is handled by the Service Control Manager (SCM), which is a part of Windows. The SCM is responsible for the creation and activation of the

COM object on the server computer. In the case of DCOM, the SCM will attempt to launch the server on the remote computer.

Figure 1. DCOM System Relationships.

Once the remote COM server has been created, all calls will be marshaled through the proxy and stub objects. The proxy and stub

communicate using RPCs (Remote Procedure Calls), which handle all the network interaction. On the server side, the stub object takes care of

marshaling. On the client, the proxy does the work.

The transmittal of data across the network is taken care of by RPC. Actually, DCOM uses an extended type of RPC called an Object RPC, or

ORPC. RPCs can run on a number of protocols, including TCP/IP, UDP, NetBEUI, NetBIOS, and named pipes. The standard RPC protocol is UDP

(User Datagram Protocol). UDP is a connectionless protocol, which seems like a bad fit for a connection-oriented system like DCOM. This isn't a

problem however; DCOM automatically takes care of connections.

As you can see, distributed COM is accomplished through a complex interaction of different hardware, operating system, and software

components. You should realize two important things from this: a) COM does a lot of work behind the scenes, and b) there are a lot of things

that can go wrong.

At the time of writing, only the TCP/IP protocol is available for DCOM data transfer on Windows 95/98 systems. This can be an annoying

limitation, requiring you to install TCP/IP on all Windows 95 systems, even when other network protocols are available.