A few years ago when using DCOM to write simple distributed applications, I was fascinated with DCOM. However, I started to doubt this technology soon, and was gradually disappointed with it. Recently, I had time to work with sockets. After diagnosing DCOM net data communication with net tools, and comparing it with sockets, I found that DCOM kills efficiency of TCP/IP net data communication and DCOM net data communication is very inefficient. Here is the recommended article for you to read. Additionally, I also put two samples, socket development guide and speed test to let you test it. MS highly recommends us three-tier development and pushing all (or as many as possible) of logical operations into the middle tier. After reading these articles, you will understand the essence of this recommendation more deeply. The essence of this recommendation is to avoid bad DCOM net data traffic between a client and a server over Internet/intranet.
You maybe disagree with me, and say that my DCOM client-server application system works well to me. That is true only if a limited number of clients are connected to your DCOM server. That will be false if a large number of clients are involved. In this article, I will show you with a sample how to offset weaknesses of DCOM with sockets for improving your DCOM server application performance a lot.
Weaknesses of DCOM
What are the weaknesses of DCOM? Here is a list of them:
- Net efficiency is very low.
- DCOM calls are synchronous only, and can not be asynchronous. Connection points are faked asynchronous calls. This weakness complicates client side development in many cases. In order to solve slow calls problem, your DCOM clients will have to use threads to prevent client graphical user interfaces from being frozen. Threads will certainly hurt you if your application becomes large and complicated.
- Your client applications never batch multiple calls into one. Lost of net data round-trips are involved.
- Many others like slow initialization server object and security setup etc.
A perfect solution to DCOM with socket
What advantages does sockets have? If you read the above recommended articles, you will know the following advantages with sockets.
- Net efficiency is better. If a batch of calls are involved, socket net efficiency is much better than DCOM.
- Socket supports both synchronous and asynchronous calls. This feature definitely simplifies your client application development a lot. You will have much less chance to use worker threads to prevent client graphical user interfaces from being frozen.
- Your client applications could easily batch multiple calls into one with less code or without any code. Net data round-trips are reduced.
- Your client applications can run multiple socket connections to a server. Each of the connections run independently and in parallel without creating any worker threads. You can use different socket sessions to process different calls at the same time.
What disadvantages does sockets have? Here is the list of socket disadvantages:
- It is difficult to program server side applications because of multiple threads problem.
- You must handle socket security.
I already solved the above two socket problems for you. See the above articles. Attached with this example, you will find a socket-nized DCOM server with full C++ source code. Additionally you will see a VB client application with source code. It demonstrates the advantages of combination of sockets and DCOM. It uses strong points of DCOM to offset socket weakness (security) in Windows platforms, and also uses strong points of socket to offset weaknesses of DCOM too. No hacker is able to directly hack this application socket communication unless the hacker hacks Windows DCOM system first.
All of the applications included with this particular package are free with the following limitations:
- A free/trial version of SocketPro server application only supports accepting 16 client connections only.
- All of SocketPro client components are totally free to you. You can download the latest SocketPro with its documentation and samples here.
- Authentication of both server applications, MultipleSvs.exe and MultiSvs.exe, are disabled for your easy setup and testing. You should pay enough attention to security. If not, someone may access your server machine files and manage them through the server application.