tags:

views:

90

answers:

3

Hi

I have a old school c program that now and then need to tell a C++ Qt based application about some "events" that has occurred on my system.

But when I started to work with this problem I noticed that some ipc techniques is quite easy to use in the c program. And then we have some Qt specific styles that works quite well in the "Qt world", but they will not work well in the ansi c program.

Do you have any advice on ipc techniques that works well and are easy to use in both a Qt C++ and a c program?

Thanks Johan

+4  A: 

What about named pipes? You can operate on them just like on regular files (creation is a bit different of course), and I bet both old ANSI C programs and new Qt C++ programs can operate on files.

Vinko Vrsalovic
I have been thinking about using named pipes and maybe help out with inotify if needed.
Johan
+5  A: 

If you are familiar with network programming, Unix domain sockets should be easy also. They work kind of like bidirectional named pipes and the network API in Qt should make it easy to receive "events" delivered as network messages.

Edgar Bonet
+1  A: 

If the event notifications are very simple then you could use signals.

If the notification is useful from/to outside sources then D-Bus is an option.

Ignacio Vazquez-Abrams
Unix signals are easy to use in the c program, but in the Qt world they are a little bit messy to get going... as your example shows. They don't really integrate well in the "Qt world".
Johan
Johan is correct. Unix signals and Qt are not a good match. D-Bus requires a lot of setup in C. Local sockets or named pipes are a better option.
andref
By the way, I tried to get that unix signal example to run... but it is not working at all (strange since most Qt examples usually runs quite well...) Have you tried to get that example running?
Johan
I don't do Qt, so no.
Ignacio Vazquez-Abrams
I got it working: http://developer.qt.nokia.com/forums/viewthread/1227/
Johan