Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
Handshake.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
7#include <PhosphorChannel/phosphorchannel_export.h>
8
9#include <cstddef>
10#include <memory>
11#include <string>
12#include <vector>
13
14// The handover of a ring from its writer to its reader over a connected Unix
15// stream socket: the memfd and the reader's wake socket go across with
16// SCM_RIGHTS, with the protocol version and the codec tag. A raw socket, not
17// one of phosphor-ipc: QLocalSocket does not pass file descriptors cleanly.
18//
19// The writer offers, the reader accepts, and the reader answers whether it
20// took the ring. Either end refuses a version that is not its own, and the
21// message names both versions. Both calls block up to their timeout, -1 for
22// no limit.
23//
24// A failed handshake can leave bytes of the other end in the socket, and a
25// ring that failed after its offer went out may still have a reader. After
26// a failure, close the socket and destroy the ring.
27
28namespace PhosphorChannel {
29
32{
36 std::vector<std::string> codecs;
37};
38
42PHOSPHORCHANNEL_EXPORT bool offerRing(int socket, RingWriter& ring, int timeoutMs, std::string* error);
43
46PHOSPHORCHANNEL_EXPORT std::unique_ptr<RingReader> acceptRing(int socket, const AcceptOptions& options, int timeoutMs,
47 std::string* error);
48
49} // namespace PhosphorChannel
Definition Ring.h:49
static constexpr std::size_t MaxCapacity
Definition Ring.h:53
Definition Channel.h:29
PHOSPHORCHANNEL_EXPORT std::unique_ptr< RingReader > acceptRing(int socket, const AcceptOptions &options, int timeoutMs, std::string *error)
Receives a ring over socket, maps it, and answers whether it took it.
PHOSPHORCHANNEL_EXPORT bool offerRing(int socket, RingWriter &ring, int timeoutMs, std::string *error)
Sends ring over socket and waits for the answer.
What a reader takes.
Definition Handshake.h:32
std::size_t maxCapacity
The largest data area, in bytes.
Definition Handshake.h:34
std::vector< std::string > codecs
The codecs that this end reads. Empty: any.
Definition Handshake.h:36