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

IPC client implementation using Unix domain sockets. More...

#include <socket_client.hpp>

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

Public Member Functions

 SocketClient (std::string socket_path)
 
 ~SocketClient () override
 
 SocketClient (const SocketClient &)=delete
 
SocketClientoperator= (const SocketClient &)=delete
 
 SocketClient (SocketClient &&)=delete
 
SocketClientoperator= (SocketClient &&)=delete
 
bool connect () override
 Connect to the server.
 
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)
 
void release (size_t message_size) override
 Release the previously received message.
 
void close () override
 Close the connection.
 
- Public Member Functions inherited from bb::ipc::IpcClient
 IpcClient ()=default
 
virtual ~IpcClient ()=default
 
 IpcClient (const IpcClient &)=delete
 
IpcClientoperator= (const IpcClient &)=delete
 
 IpcClient (IpcClient &&)=delete
 
IpcClientoperator= (IpcClient &&)=delete
 

Private Member Functions

void close_internal ()
 

Private Attributes

std::string socket_path_
 
int fd_ = -1
 
std::vector< uint8_t > recv_buffer_
 

Additional Inherited Members

- Static Public Member Functions inherited from bb::ipc::IpcClient
static std::unique_ptr< IpcClientcreate_socket (const std::string &socket_path)
 
static std::unique_ptr< IpcClientcreate_shm (const std::string &base_name)
 

Detailed Description

IPC client implementation using Unix domain sockets.

Direct implementation with no wrapper layer - manages socket connection directly.

Definition at line 18 of file socket_client.hpp.

Constructor & Destructor Documentation

◆ SocketClient() [1/3]

bb::ipc::SocketClient::SocketClient ( std::string  socket_path)
explicit

Definition at line 14 of file socket_client.cpp.

◆ ~SocketClient()

bb::ipc::SocketClient::~SocketClient ( )
override

Definition at line 18 of file socket_client.cpp.

◆ SocketClient() [2/3]

bb::ipc::SocketClient::SocketClient ( const SocketClient )
delete

◆ SocketClient() [3/3]

bb::ipc::SocketClient::SocketClient ( SocketClient &&  )
delete

Member Function Documentation

◆ close()

void bb::ipc::SocketClient::close ( )
overridevirtual

Close the connection.

Implements bb::ipc::IpcClient.

Definition at line 106 of file socket_client.cpp.

◆ close_internal()

void bb::ipc::SocketClient::close_internal ( )
private

Definition at line 111 of file socket_client.cpp.

◆ connect()

bool bb::ipc::SocketClient::connect ( )
overridevirtual

Connect to the server.

Returns
true if connection successful, false otherwise

Implements bb::ipc::IpcClient.

Definition at line 23 of file socket_client.cpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ receive()

std::span< const uint8_t > bb::ipc::SocketClient::receive ( uint64_t  timeout_ns)
overridevirtual

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.

Implements bb::ipc::IpcClient.

Definition at line 73 of file socket_client.cpp.

◆ release()

void bb::ipc::SocketClient::release ( size_t  message_size)
overridevirtual

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)

Implements bb::ipc::IpcClient.

Definition at line 101 of file socket_client.cpp.

◆ send()

bool bb::ipc::SocketClient::send ( const void *  data,
size_t  len,
uint64_t  timeout_ns 
)
overridevirtual

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

Implements bb::ipc::IpcClient.

Definition at line 50 of file socket_client.cpp.

Member Data Documentation

◆ fd_

int bb::ipc::SocketClient::fd_ = -1
private

Definition at line 39 of file socket_client.hpp.

◆ recv_buffer_

std::vector<uint8_t> bb::ipc::SocketClient::recv_buffer_
private

Definition at line 40 of file socket_client.hpp.

◆ socket_path_

std::string bb::ipc::SocketClient::socket_path_
private

Definition at line 38 of file socket_client.hpp.


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