Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::ipc::DomainSocket Class Reference

Low-level RAII abstraction for UNIX Domain Datagram Sockets (AF_UNIX / SOCK_DGRAM). Provides discrete, boundary-preserving, zero-fragmentation message passing. More...

#include <DomainSocket.hpp>

+ Collaboration diagram for corium::ipc::DomainSocket:

Public Member Functions

bool bind (const std::string &socketPath) noexcept
 Bind socket to a filesystem path as a receiving server.
 
void close () noexcept
 Close socket and unlink bound file if server.
 
bool connect (const std::string &socketPath, const std::string &clientPath="") noexcept
 Connect to a destination socket as a client.
 
 DomainSocket () noexcept=default
 
 DomainSocket (const DomainSocket &)=delete
 
 DomainSocket (DomainSocket &&other) noexcept
 
bool isOpen () const noexcept
 Check if socket descriptor is open.
 
int nativeHandle () const noexcept
 Access underlying OS file descriptor.
 
DomainSocketoperator= (const DomainSocket &)=delete
 
DomainSocketoperator= (DomainSocket &&other) noexcept
 
int receive (void *buffer, std::size_t maxLength) noexcept
 Receive datagram packet from socket.
 
int send (const void *buffer, std::size_t length) noexcept
 Send datagram packet over the connected socket.
 
void setNonBlocking (bool nonBlocking) noexcept
 Set socket non-blocking mode.
 
 ~DomainSocket ()
 

Detailed Description

Low-level RAII abstraction for UNIX Domain Datagram Sockets (AF_UNIX / SOCK_DGRAM). Provides discrete, boundary-preserving, zero-fragmentation message passing.

Constructor & Destructor Documentation

◆ DomainSocket() [1/3]

corium::ipc::DomainSocket::DomainSocket ( )
defaultnoexcept

◆ ~DomainSocket()

corium::ipc::DomainSocket::~DomainSocket ( )
inline
+ Here is the call graph for this function:

◆ DomainSocket() [2/3]

corium::ipc::DomainSocket::DomainSocket ( const DomainSocket )
delete

◆ DomainSocket() [3/3]

corium::ipc::DomainSocket::DomainSocket ( DomainSocket &&  other)
inlinenoexcept

Member Function Documentation

◆ bind()

bool corium::ipc::DomainSocket::bind ( const std::string &  socketPath)
inlinenoexcept

Bind socket to a filesystem path as a receiving server.

Parameters
socketPathFilesystem path for the socket (e.g. "/tmp/corium_daemon.sock").
Returns
true on success, false otherwise.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ close()

void corium::ipc::DomainSocket::close ( )
inlinenoexcept

Close socket and unlink bound file if server.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ connect()

bool corium::ipc::DomainSocket::connect ( const std::string &  socketPath,
const std::string &  clientPath = "" 
)
inlinenoexcept

Connect to a destination socket as a client.

Parameters
socketPathFilesystem path of the target server socket.
clientPathOptional path to bind this client for bidirectional responses.
Returns
true on success, false otherwise.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isOpen()

bool corium::ipc::DomainSocket::isOpen ( ) const
inlinenoexcept

Check if socket descriptor is open.

+ Here is the caller graph for this function:

◆ nativeHandle()

int corium::ipc::DomainSocket::nativeHandle ( ) const
inlinenoexcept

Access underlying OS file descriptor.

◆ operator=() [1/2]

DomainSocket & corium::ipc::DomainSocket::operator= ( const DomainSocket )
delete

◆ operator=() [2/2]

DomainSocket & corium::ipc::DomainSocket::operator= ( DomainSocket &&  other)
inlinenoexcept
+ Here is the call graph for this function:

◆ receive()

int corium::ipc::DomainSocket::receive ( void *  buffer,
std::size_t  maxLength 
)
inlinenoexcept

Receive datagram packet from socket.

Parameters
bufferDestination buffer.
maxLengthMaximum bytes to receive.
Returns
Number of bytes received, or -1 on error/EWOULDBLOCK.
+ Here is the caller graph for this function:

◆ send()

int corium::ipc::DomainSocket::send ( const void *  buffer,
std::size_t  length 
)
inlinenoexcept

Send datagram packet over the connected socket.

Parameters
bufferPointer to payload.
lengthPayload length in bytes.
Returns
Number of bytes sent, or -1 on error.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setNonBlocking()

void corium::ipc::DomainSocket::setNonBlocking ( bool  nonBlocking)
inlinenoexcept

Set socket non-blocking mode.

+ Here is the caller graph for this function:

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