Qt supports many ways of communicating with other processes running in the same system or in different systems. There are basically three types of inter-process communication mechanisms:
- Synchronization primitives
- Exchanging of arbitrary byte-level data
- Passing structured messages
Qt only provides one class for explicit inter-process synchronization: QSystemSemaphore. A QSystemSemaphore is like a QSemaphore that is accessible by multiple processes in the same system. It is globally identified by a "key", which in Qt is represented by the QNativeIpcKey class. Additionally, depending on the OS, Qt may support multiple different backends for sharing memory; see the Native IPC Keys documentation for more information and limitations.
It is possible to use regular thread-synchronization primitives such as mutexes, wait conditions, and read-write locks, located in memory that is shared between processes. Qt does not provide any class to support this, but applications can use low-level operations on certain operating systems.
Using byte-level data, applications can implement any communication protocol they may choose. Sharing of byte data can be stream-oriented (serialized) or can allow random access (a similar condition to QFileDevice::isSequential()).
For serial communication, Qt provides a number of different classes and even full modules:
- Pipes and FIFOs: QFile
- Child processes: QProcess
- Sockets: QTcpSocket, QUdpSocket (in Qt Network)
- HTTP(S): QNetworkAccessManager (in Qt Network) and QHttpServer (in Qt HTTP Server)
- CoAP(S): QCoapClient (in Qt CoAP)
Qt also provides a number of techniques to exchange structured messages with other processes. Applications can build on top of the byte-level solutions above, such as by using QJsonDocument or QXmlStreamReader / QXmlStreamWriter over HTTP to perform JSONRPC or XMLRPC, respectively, or QCborValue with QtCoAP.
Dedicated Qt modules for structured messages and remote procedure-calling include:
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.