Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
socket_client.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <cstddef>
5#include <cstdint>
6#include <span>
7#include <string>
8#include <sys/types.h>
9#include <vector>
10
11namespace bb::ipc {
12
18class SocketClient : public IpcClient {
19 public:
20 explicit SocketClient(std::string socket_path);
21 ~SocketClient() override;
22
23 // Non-copyable, non-movable (owns file descriptor)
24 SocketClient(const SocketClient&) = delete;
28
29 bool connect() override;
30 bool send(const void* data, size_t len, uint64_t timeout_ns) override;
31 std::span<const uint8_t> receive(uint64_t timeout_ns) override;
32 void release(size_t message_size) override;
33 void close() override;
34
35 private:
36 void close_internal();
37
38 std::string socket_path_;
39 int fd_ = -1;
40 std::vector<uint8_t> recv_buffer_; // Internal buffer for socket recv
41};
42
43} // namespace bb::ipc
Abstract interface for IPC client.
IPC client implementation using Unix domain sockets.
void release(size_t message_size) override
Release the previously received message.
SocketClient & operator=(const SocketClient &)=delete
SocketClient(SocketClient &&)=delete
bool connect() override
Connect to the server.
SocketClient(const SocketClient &)=delete
bool send(const void *data, size_t len, uint64_t timeout_ns) override
Send a message to the server.
std::span< const uint8_t > receive(uint64_t timeout_ns) override
Receive a message from the server (zero-copy for shared memory)
SocketClient & operator=(SocketClient &&)=delete
std::vector< uint8_t > recv_buffer_
void close() override
Close the connection.
const std::vector< MemoryValue > data
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
uint8_t len