[Qt-interest] Multiple Process
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Mon Mar 22 10:24:26 CET 2010
Diego Iastrubni wrote on Monday, March 22, 2010 8:30 AM:
> There are several IPC examples in Qt, look at them (IPC =
> http://en.wikipedia.org/wiki/Inter-process_communication )
>
> You can use a shared memory, dbus, or use QRemoteSignal:
> http://qt-apps.org/content/show.php/QRemoteSignal?content=112061
Besides all these very good examples, as to control a "remote application" (lets focus on processes which run on the *same* local computer, for sake of simplicity. E.g. DBus was (originally) designed exactly for (just) this scenario), you could also use the simple communication via "stdin/stdout".
This off course assumes that your external process keeps listening on "stdin" file descriptor for "commands".
So once you have started your external process using QProcess, you can "write" comands (simple strings, for example) to that process using http://doc.trolltech.com/4.6/qprocess.html#writeData. Likewise you can read the response of the process with readData() (e.g. the result of a given command). Off course terminating and waiting for a process to be terminated is also all supported by QProcess.
I think "MPlayer" works like this, see http://www.mplayerhq.hu/DOCS/HTML/en/control.html#slave-mode
If you want that your process can also communicate with other applications adhering to some standard then you could go for http://doc.trolltech.com/4.6/qtdbus.html, which is mentioned above. It is off course a bit more complicated than writing/reading via simple stdin/stdout ;) The drawback is also that currently DBus is not yet supported on Windows (there is an effort going on in porting DBus to Windows, but to my knowledge it is still in alpha stage and Qt does not compile with it. I might be wrong though. Refer to http://sourceforge.net/projects/windbus/)
Off course there are many other possibilities for processes to communicate, not to forget via network protocols (and then off course also remotely) or via shared memory. http://doc.trolltech.com/4.6/ipc.html sums it all up. QRemoteSignal is also very interesting, I did not know this one before.
Cheers,
Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list