Pages
API Documentation
On this page

Sonic::Ipc::Server Class

Listens on a local socket. More...

  • Header: #include <Sonic/Ipc/Server>
  • CMake: find_package(SonicIpc REQUIRED)
    target_link_libraries(mytarget PRIVATE Sonic::Ipc)
  • Inherits: QObject

List of all members, including inherited members

Public Types

Public Functions

Signals

Static Public Members

Detailed Description

Wraps each client in a Connection, parented to this server and deleted when it disconnects.

Member Type Documentation

enum Server::Access

Who may connect to the socket.

Constant Value Description
Sonic::Ipc::Server::Access::User 0 Owner only (QLocalServer::UserAccessOption).
Sonic::Ipc::Server::Access::Group 1 Owner and group.
Sonic::Ipc::Server::Access::World 2 Everyone.

Member Function Documentation

[explicit] Server::Server(QObject *parent = nullptr)

Creates a server that isn't listening yet, with the given parent.

void Server::broadcast(quint32 type, QByteArrayView payload)

Sends a frame of type with payload to every connection.

void Server::close()

Closes every connection and stops listening.

QList<Sonic::Ipc::Connection *> Server::connections() const

The connected clients.

QString Server::errorString() const

Why listen() failed.

QString Server::fullServerName() const

The socket's file path; callers that hand the socket to another uid chown this after listen().

bool Server::listen(const QString &nameOrPath, Sonic::Ipc::Server::Access access, quint16 protocolVersion, qint64 maxPayload = defaultMaxPayload)

Passes nameOrPath to QLocalServer::listen() unchanged. Fails while another server answers on it, so a live server is never replaced; a stale socket file is removed and listened on.

access says who may connect. Connections speak application protocol protocolVersion and reject payloads larger than maxPayload bytes.

[signal] void Server::newConnection(Sonic::Ipc::Connection *connection)

A client connected; connection belongs to the server.

[static] QString Server::userSocketPath(const QString &fileName)

<RuntimeLocation>/fileName, or /tmp/sonic-<uid>/fileName when Qt has no runtime location. The /tmp directory is created with mode 0700 and refused (empty result) if it is a symlink, not a directory, owned by another user, or open to group or others.

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