Legacy process and new Qt enable process



  • Hi - I'm working on a new system where I have a process that does network communication out to other computers in the system. It is code that I don't want to touch, and all I want to have it do is send a command to my new fancy Qt enabled process. Also, once a second the new process is going to send back a packet of status data to the legacy process, which will format it and send it out.

    Is there an IPC mechanism I can use that would enable this? Do I have to use an event, or can I use something like a QSocketNotifier. I guess it would be preferable to not have to use Qt libraries in the legacy process. What do you all think would be the best (and by best I mean easiest) way to do this?

    M



  • What does "network communication" mean? Qt supports "TCP":http://doc.qt.nokia.com/latest/qtcpsocket.html and "UDP":http://doc.qt.nokia.com/latest/qudpsocket.html out of the box. For local IPC there are "local sockets":http://doc.qt.nokia.com/latest/qlocalsocket.html as well (domain sockets, named pipes) as "shared memory":http://doc.qt.nokia.com/latest/qsharedmemory.html or "D-Bus":http://doc.qt.nokia.com/latest/qtdbus.html.

    Qt also supports system-independent "timers":http://doc.qt.nokia.com/latest/qtimer.html which can be used to invoke pieces of code in regular intervals.

    If it is networked communcation go for TCP or UDP (depending on your needs), otherwise you could use a local socket as well (which, in addition, means that your code can be easily upgraded to TCP or UDP or later on).



  • Network communication means the legacy code is opening TCP sockets and communicating with the computer that is the main controller for the whole system. I don't want to touch any of that because there is a protocol on top of TCP and it all "just works". So the networking stuff can simply be left alone. However, when a command comes in over the network, I want to be able to shove it through some IPC mechanism to my new software.

    I don't want to include Qt in the legacy process. Is there some IPC I can use (I'm running on Linux) in the legacy side that has a Qt coutnerpart? message queue? I'm not getting what QSocketNotifier does...



  • [quote author="medvedm" date="1314973517"]I'm not getting what QSocketNotifier does...[/quote]
    Basically, it uses something like select or epoll on a standard file descriptor to emit a Qt signal whenever it is ready either to read, write, or it has errors.
    You would still have to read it with either the standard C read function, or a QIODevice wrapped around it (with QFile::open(int fd,...) or QTcpSocket::setSocketDescriptor(int fd,...) (but QTcpSocket does already the notification part, so you wouldn't need to use QSocketNotifier with it)).



  • Use a domain socket, QLocalSocket resp. QLocalServer is the Qt counterpart. Or you just use QSocketNotifier and ordinary read/write methods as already suggested (example usage see "here":http://developer.qt.nokia.com/forums/viewthread/9254/).


Log in to reply
 

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