Communication between Child and Parent Process



  • Hi,

    I would like to write a child and parent process, in which the parent process will start the child process. The main goal is that child an parent can communicate together, but I would prefer not using stdout/stderr to communicate.

    The communication is more in a way of request response and should be fast.

    Example:

    • Parent process starts child process
    • Parent process sends request to child process
    • Child process send response to parent process
    • Child process terminates

    What kind of implementation for this sort of communication method are you recommending?

    Regards,
    Stefan


  • Qt Champions 2016

    @walteste
    If you don't want to use the standard streams, and provided the parent and child processes are applications you're developing you have few other options. You could use d-bus if you're developing on Linux, or you could communicate through local sockets (my preferred solution).



  • @kshegunov, are you refering to QLocalSocket class?
    I had a look at this as well and think that this is exactly what I am looking for.

    Do you have experience regarding performance of QLocalSocket?


  • Qt Champions 2016

    @walteste

    are you refering to QLocalSocket class?

    Indeed, QLocalSocket and QLocalServer should suit you fine.

    Do you have experience regarding performance of QLocalSocket?

    If you're asking about speed, the local socket is very fast, although how fast exactly depends on the platform implementation. From my experience on Linux they're lightning fast (I believe shared memory mapping is used at the kernel level), on windows, not so much, but in any case it should be at least several times faster than reading/writing to HDD.

    Kind regards.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.