Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Communicating with Remote Processes without DCOM or CORBA

0.00/5 (No votes)
30 Apr 2001 1  
Introduce a new interprocess communication tool
  • Download XYMessenger, its documentation, related tools, and sample code - 1.11 Mb
  • Introduction

    Sure, there may be a thousand different ways to do interprocess communication without using DCOM or CORBA. But my knowledge in this area is very limited. As a matter of fact, I don't know that much about DCOM and CORBA, either. I use ActiveX/COM daily in my work, but never DCOM. I understand that DCOM and CORBA are general communication protocols that can be used to build wonderful client-server systems. After some reading, I found out that programming with CORBA is not easy and I also found out that some other people agree with me. DCOM is not that hard to me since I already know how to use COM, but can I use it in platforms other than Win32, say AIX, without writing tons of low level code to support it?

    Here is what I need most: a simple way to send a block of bytes of any size (a message) from one process to another. The process receiving it should be able to send a reply message back to the original sender. How the blocks of bytes (the message and the reply) are interpreted are strictly the business of the sender and the receiver. That is, the message could be the contents of a file, or a record in an Oracle table, or any other data.

    That is easy, you may say. Just open a socket connection between the two processes and send the message (the block of bytes). But I want more. I want to be able to connect more processes (may be 100 or may be 1000) together in a way that any connected process can send a message to any other connected process. I want messages to be sent in two ways, synchronous and asynchronous. By synchronous I mean the "send" function will not return until the receiver "reply" to the message or time-out occurs.

    Here is my solution. I will start one process as the root server. Then one or more processes can be connected to the root server. Each of these processes can have one or more processes connected to it. All the connected processes form a tree structure. I call it the Communication Tree. Any two processes within the same tree will be able to to communicate with each other by sending and receiving messages. Of course, if the two processes are not directly connected, then the messages between them have to be routed by one or more intermediate processes. Note that each process needs only to "connect" once to join the Communication Tree.

    This must be more complicated than learning DCOM or CORBA (assuming you can use DCOM or CORBA to implement the above features), right? Wrong! Because all the code implementing the above features can be wrapped in a single component (a black box). This component is an ActiveX control I wrote. It is a very small control considering what it can do. Of course, I spent a lot of weekend and vacation time to write it. The good news is, it is a general control that can be reused in all VB and VC++ (MFC) programs. All you need to do is inserting it into your programs and your programs will be able to talk to each other by calling methods of this control. By the way, the control is named XYMessenger.

    What about other platforms? The answer is, I have ported XYMessenger to Java. XYMessenger is also the name of a Java class. This class has almost identical methods as the ActiveX control with the same name. And they are compatible. That is, Java programs using the XYMessenger class can communicate with Win32 programs using the XYMessenger control.

    What is the use of XYMessenger, if the only kind of message it can send or receive is a block of bytes? I wrote other useful tools that can turn a complicated data object into a block of bytes so that it can be send via a message and restore the object from the block of bytes once the message is received.

    For the latest version of XYMessenger, its documentation, other related tools, as well as sample code, check my website. The package actually contains some other cool stuff, which I will probably introduce in another article.

    I understand that my solution has its limitations, too. And it cannot replace any general protocol. Please e-mail me your comments (I may not be able to answer all mails, however).

    History

    1 May 2001 - updated source files

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here