Interprocess communication

Posted on 2003-03-23
Medium Priority
Last Modified: 2012-06-27

do you have a good sample program that illustrates the communication via pipes between two C++ programs?
Is it possible to establish communication between a matlab.exe and a VisualC++.exe via pipelines?
Do you have some good information about this topic?

Thanks a lot,
kind regards,
Geert Craessaerts
Question by:Geert2003
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Expert Comment

ID: 8190905
> Is it possible to establish communication between a matlab.exe and a VisualC++.exe via pipelines?

IMHO, pipes doesn't work between VC++ and Matlab because pipes is 'unknown terminology' on Windows.

I'm confused about what do you want to do.
If you want to communicate between VisualC++.exe and Matlab.exe (both are ready made executable) then the only posible way is by using DDE (Dynamic data exchange). Matlab.exe is able to act as DDE server or DDE client (try to type 'help dde' from Matlab command line). I can easily exchange data (matrix/table) between Matlab and Excel with this facility. However, I have no idea why do you want Matlab.exe to communicate with visualC++.

If, on the other hand, you want to communicate between Matlab.exe and another.exe made by Visual C++, then it  make sense. The complete Matlab package contains toolkit called Matlab-compiler. That toll-kit allows you to :
1. Make a C++ program (exe) that use Matlab library, so you can have powerfull matrix routine in your C++ program.
2. Make a C++ library (dll) that can be called from Matlab M-script. You may want to do this to make a fast routine, compare to usual M-file.

So please tell us which one is your intention ? If you say what is your application, we may give you better suggestion.


Author Comment

ID: 8191339

I've written a control interface program in VisualC++ that has to communicate with Matlab because the control algorithms are written in Matlab. Every 200ms a VisualC++ program retrieves data from the machine and has to send this information to Matlab. Matlab performs the control algorithm and sends his output back to Visual C++. In a next step Visual C gives the information to the machine.

I've tried to establish a communication by using the matlab engine. But if I want to run the program on another computer, this computer will always need Matlab.
So I want to establish a communication between two executables(one from the Matlab program and one from the Visual C++ program) I've seen that this is possible between two C++ programs so I would think that it should also be possible between Matlab and VisualC++?
I thought that I should compile the matlab code in C++ code at first instance. Then I think I should write the code for establishing pipelines in both C++ code-programs and in a last step I should compile these two C++-code programs. Am I right?

A second question; Is it possible to exchange commandos between two applications via pipes?

Thanks a lot,
kind regards,
Geert Craessaerts

Accepted Solution

Kocil earned 500 total points
ID: 8193855
That's a good system.

Yes, you may achieve that by using DDE (not pipes).
The system may work like this:

1. On Matlab, you have to make M-File that use matlab dde to act as a DDE server. See your Matlab documentation for DDE.

2. Your C++ program has to act as DDE client.

DDE is very convenient:
* You may send any data (commands, string, integer, float, image, etc) between DDE client and server.
* DDE can send the data across the network, so your Matlab and C++ program may run on different computer.

I did this long time ago, I'll see if I can find that old codes.

Expert Comment

ID: 8207861
Hi, bad news.

My old code, it was made for Matlab 4.0, does not work anymore. I just found out that Matlab 6 has changed everything:
1. dde is now in winfun package. Try help winfun
2. Matlab can not act as dde server
So my previous suggestion must be reversed.
Your C++ program has to act as DDE server, and Matlab as a client with ddeack.

My friend said, she is the Matlab woman here, you have two more choices:
1. Matlab 6 can do good user interface now. Why not using it instead of using C++ ?
2. Use Realtime Toolbox to link VC++ and Matlab.


LVL 11

Expert Comment

ID: 9544046
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered: Points to Kocil

Please leave any comments here within the next seven days. Experts: Silence
means you don't care.


-bcl (bcladd)
EE Cleanup Volunteer

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question