Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::ipc::UdsChannel< EventVariant, MaxPacketSize > Class Template Reference

Typed IPC channel operating over UNIX Domain Datagram Sockets. Provides boundary-preserving, discrete event transmission with zero packet fragmentation. More...

#include <UdsChannel.hpp>

+ Collaboration diagram for corium::ipc::UdsChannel< EventVariant, MaxPacketSize >:

Public Member Functions

void close () noexcept
 Close the socket connection and unlink socket file if server.
 
bool connect (const std::string &serverPath, const std::string &clientPath="") noexcept
 Connect as a client to a server socket path.
 
bool isOpen () const noexcept
 Check if socket is open.
 
bool listen (const std::string &socketPath, bool nonBlocking=true) noexcept
 Start listening as an IPC server on a filesystem socket path.
 
template<typename EventType >
bool post (EventType &&event) noexcept
 Post a typed event over the socket to the remote receiver.
 
template<typename SinkType >
std::size_t pumpInto (const SinkType &sink, std::size_t maxEvents=0)
 Drain incoming UNIX domain socket events into a target event sink.
 
DomainSocketsocket () noexcept
 Access underlying DomainSocket instance.
 
bool tryPop (EventVariant &outEvent) noexcept
 Try popping one pending datagram event from the socket (non-blocking).
 
 UdsChannel ()=default
 

Detailed Description

template<typename EventVariant = DefaultEvents, std::size_t MaxPacketSize = 512>
class corium::ipc::UdsChannel< EventVariant, MaxPacketSize >

Typed IPC channel operating over UNIX Domain Datagram Sockets. Provides boundary-preserving, discrete event transmission with zero packet fragmentation.

Template Parameters
EventVariantSupported event variant list (must be trivially copyable or POD).
MaxPacketSizeMaximum serialized datagram packet buffer size (default 512 bytes).

Constructor & Destructor Documentation

◆ UdsChannel()

template<typename EventVariant = DefaultEvents, std::size_t MaxPacketSize = 512>
corium::ipc::UdsChannel< EventVariant, MaxPacketSize >::UdsChannel ( )
default

Member Function Documentation

◆ close()

template<typename EventVariant = DefaultEvents, std::size_t MaxPacketSize = 512>
void corium::ipc::UdsChannel< EventVariant, MaxPacketSize >::close ( )
inlinenoexcept

Close the socket connection and unlink socket file if server.

+ Here is the call graph for this function:

◆ connect()

template<typename EventVariant = DefaultEvents, std::size_t MaxPacketSize = 512>
bool corium::ipc::UdsChannel< EventVariant, MaxPacketSize >::connect ( const std::string &  serverPath,
const std::string &  clientPath = "" 
)
inlinenoexcept

Connect as a client to a server socket path.

Parameters
serverPathServer destination socket path.
clientPathOptional client socket path for bidirectional reply.
Returns
true on success, false otherwise.
+ Here is the call graph for this function:

◆ isOpen()

template<typename EventVariant = DefaultEvents, std::size_t MaxPacketSize = 512>
bool corium::ipc::UdsChannel< EventVariant, MaxPacketSize >::isOpen ( ) const
inlinenoexcept

Check if socket is open.

+ Here is the call graph for this function:

◆ listen()

template<typename EventVariant = DefaultEvents, std::size_t MaxPacketSize = 512>
bool corium::ipc::UdsChannel< EventVariant, MaxPacketSize >::listen ( const std::string &  socketPath,
bool  nonBlocking = true 
)
inlinenoexcept

Start listening as an IPC server on a filesystem socket path.

Parameters
socketPathFilesystem path (e.g. "/tmp/corium_control.sock").
nonBlockingIf true, enables non-blocking mode for non-waiting event loop polling.
Returns
true on success, false otherwise.
+ Here is the call graph for this function:

◆ post()

template<typename EventVariant = DefaultEvents, std::size_t MaxPacketSize = 512>
template<typename EventType >
bool corium::ipc::UdsChannel< EventVariant, MaxPacketSize >::post ( EventType &&  event)
inlinenoexcept

Post a typed event over the socket to the remote receiver.

Template Parameters
EventTypeEvent type.
Parameters
eventEvent payload.
Returns
true if datagram sent, false on socket error.
+ Here is the call graph for this function:

◆ pumpInto()

template<typename EventVariant = DefaultEvents, std::size_t MaxPacketSize = 512>
template<typename SinkType >
std::size_t corium::ipc::UdsChannel< EventVariant, MaxPacketSize >::pumpInto ( const SinkType &  sink,
std::size_t  maxEvents = 0 
)
inline

Drain incoming UNIX domain socket events into a target event sink.

Template Parameters
SinkTypeTarget EventSink or compatible sink.
Parameters
sinkTarget sink instance.
maxEventsMaximum events to drain (0 = drain all pending).
Returns
Number of events successfully transferred into local runtime.
+ Here is the call graph for this function:

◆ socket()

template<typename EventVariant = DefaultEvents, std::size_t MaxPacketSize = 512>
DomainSocket & corium::ipc::UdsChannel< EventVariant, MaxPacketSize >::socket ( )
inlinenoexcept

Access underlying DomainSocket instance.

◆ tryPop()

template<typename EventVariant = DefaultEvents, std::size_t MaxPacketSize = 512>
bool corium::ipc::UdsChannel< EventVariant, MaxPacketSize >::tryPop ( EventVariant &  outEvent)
inlinenoexcept

Try popping one pending datagram event from the socket (non-blocking).

Parameters
outEventReference populated with received event variant.
Returns
true if an event was received, false if socket has no pending datagrams.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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