Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::ipc::IpcClient Class Referenceabstract

Abstract interface for IPC client. More...

#include <ipc_client.hpp>

Inheritance diagram for bb::ipc::IpcClient:
bb::ipc::ShmClient bb::ipc::SocketClient

Public Member Functions

 IpcClient ()=default
 
virtual ~IpcClient ()=default
 
 IpcClient (const IpcClient &)=delete
 
IpcClientoperator= (const IpcClient &)=delete
 
 IpcClient (IpcClient &&)=delete
 
IpcClientoperator= (IpcClient &&)=delete
 
virtual bool connect ()=0
 Connect to the server.
 
virtual bool send (const void *data, size_t len, uint64_t timeout_ns)=0
 Send a message to the server.
 
virtual std::span< const uint8_t > receive (uint64_t timeout_ns)=0
 Receive a message from the server (zero-copy for shared memory)
 
virtual void release (size_t message_size)=0
 Release the previously received message.
 
virtual void close ()=0
 Close the connection.
 

Static Public Member Functions

static std::unique_ptr< IpcClientcreate_socket (const std::string &socket_path)
 
static std::unique_ptr< IpcClientcreate_shm (const std::string &base_name)
 

Detailed Description

Abstract interface for IPC client.

Provides a unified interface for connecting to IPC servers and exchanging messages. Implementations handle transport-specific details (Unix domain sockets, shared memory, etc).

Definition at line 18 of file ipc_client.hpp.

Constructor & Destructor Documentation

◆ IpcClient() [1/3]

bb::ipc::IpcClient::IpcClient ( )
default

◆ ~IpcClient()

virtual bb::ipc::IpcClient::~IpcClient ( )
virtualdefault

◆ IpcClient() [2/3]

bb::ipc::IpcClient::IpcClient ( const IpcClient )
delete

◆ IpcClient() [3/3]

bb::ipc::IpcClient::IpcClient ( IpcClient &&  )
delete

Member Function Documentation

◆ close()

virtual void bb::ipc::IpcClient::close ( )
pure virtual

Close the connection.

Implemented in bb::ipc::ShmClient, and bb::ipc::SocketClient.

◆ connect()

virtual bool bb::ipc::IpcClient::connect ( )
pure virtual

Connect to the server.

Returns
true if connection successful, false otherwise

Implemented in bb::ipc::ShmClient, and bb::ipc::SocketClient.

◆ create_shm()

std::unique_ptr< IpcClient > bb::ipc::IpcClient::create_shm ( const std::string &  base_name)
static

Definition at line 15 of file ipc_client.cpp.

◆ create_socket()

std::unique_ptr< IpcClient > bb::ipc::IpcClient::create_socket ( const std::string &  socket_path)
static

Definition at line 10 of file ipc_client.cpp.

◆ operator=() [1/2]

IpcClient & bb::ipc::IpcClient::operator= ( const IpcClient )
delete

◆ operator=() [2/2]

IpcClient & bb::ipc::IpcClient::operator= ( IpcClient &&  )
delete

◆ receive()

virtual std::span< const uint8_t > bb::ipc::IpcClient::receive ( uint64_t  timeout_ns)
pure virtual

Receive a message from the server (zero-copy for shared memory)

Parameters
timeout_nsTimeout in nanoseconds
Returns
Span of message data (empty on error/timeout)

The span remains valid until release() is called or the next recv(). For shared memory: direct view into ring buffer (true zero-copy) For sockets: view into internal buffer (eliminates one copy)

Must be followed by release() to consume the message.

Implemented in bb::ipc::ShmClient, and bb::ipc::SocketClient.

◆ release()

virtual void bb::ipc::IpcClient::release ( size_t  message_size)
pure virtual

Release the previously received message.

Parameters
message_sizeSize of the message being released (from span.size())

Must be called after recv() to consume the message and free resources. For shared memory: releases space in the ring buffer For sockets: no-op (message already consumed during recv)

Implemented in bb::ipc::ShmClient, and bb::ipc::SocketClient.

◆ send()

virtual bool bb::ipc::IpcClient::send ( const void *  data,
size_t  len,
uint64_t  timeout_ns 
)
pure virtual

Send a message to the server.

Parameters
dataPointer to message data
lenLength of message in bytes
timeout_nsTimeout in nanoseconds (0 = infinite)
Returns
true if sent successfully, false on error or timeout

Implemented in bb::ipc::ShmClient, and bb::ipc::SocketClient.


The documentation for this class was generated from the following files: