Pages
API Documentation
On this page

Sonic IPC

Framed peer-to-peer messages over local sockets.

Sonic IPC is a small inter-process communication library for SonicDE. It is built on Unix domain sockets (QLocalServer / QLocalSocket). Components can talk to each other directly, peer to peer, without a message bus, so D-Bus becomes an option rather than a requirement.

Each frame carries the application's protocol version and a message type. Damaged, oversized or foreign data is rejected and the connection closed; a peer speaking another protocol version is told so first. Frame type 0xFFFFFFFF is reserved for the library.

constexpr quint16 protocolVersion = 1;

auto *server = new Sonic::Ipc::Server(this);
server->listen(Sonic::Ipc::Server::userSocketPath(QStringLiteral("my-service.sock")),
               Sonic::Ipc::Server::Access::User, protocolVersion);
connect(server, &Sonic::Ipc::Server::newConnection, this, [](Sonic::Ipc::Connection *connection) {
    QObject::connect(connection, &Sonic::Ipc::Connection::frameReceived, connection,
                     [connection](quint32 type, const QByteArray &payload) {
                         connection->send(type, payload); // echo
                     });
});

Using the Module

Building with CMake

Use the find_package() command to locate the SonicIpc package and link against its target:

find_package(SonicIpc REQUIRED)
target_link_libraries(mytarget PRIVATE Sonic::Ipc)

API Reference

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.