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

Statically buffered, zero-heap UDP communication channel for distributed Corium nodes. More...

#include <StaticUdpChannel.hpp>

+ Collaboration diagram for corium::net::StaticUdpChannel< MaxPacketSize >:

Public Member Functions

void close () noexcept
 Close underlying socket.
 
bool isOpen () const noexcept
 Returns true if socket is open and bound.
 
int nativeHandle () const noexcept
 Native socket file descriptor or handle.
 
bool openAndBind (uint16_t port=0, const char *ip="0.0.0.0") noexcept
 Open UDP socket and bind to a local port and IP address.
 
StaticUdpChanneloperator= (const StaticUdpChannel &)=delete
 
StaticUdpChanneloperator= (StaticUdpChannel &&other) noexcept
 
bool receive (std::span< uint8_t > bufferOut, size_t &bytesReceivedOut) noexcept
 Receive raw bytes from incoming UDP datagram.
 
template<typename EventVariant , typename Sink >
bool receiveAndPush (Sink &sink, EventPriority priority=EventPriority::Normal) noexcept
 Receive a WirePacket and deserialize directly into a Corium EventSink.
 
template<typename Event , typename EventVariant >
bool sendEvent (const char *ip, uint16_t port, const Event &event) noexcept
 Serialize and send a typed event over UDP using Corium WirePacket framing.
 
bool sendTo (const char *ip, uint16_t port, std::span< const uint8_t > data) noexcept
 Send raw payload to target UDP endpoint.
 
bool setNonBlocking (bool nonBlocking=true) noexcept
 Set socket non-blocking mode.
 
constexpr StaticUdpChannel () noexcept=default
 
 StaticUdpChannel (const StaticUdpChannel &)=delete
 
 StaticUdpChannel (StaticUdpChannel &&other) noexcept
 
 ~StaticUdpChannel ()
 

Detailed Description

template<size_t MaxPacketSize = 512>
class corium::net::StaticUdpChannel< MaxPacketSize >

Statically buffered, zero-heap UDP communication channel for distributed Corium nodes.

Template Parameters
MaxPacketSizeMaximum UDP datagram payload size in bytes (default: 512).

Constructor & Destructor Documentation

◆ StaticUdpChannel() [1/3]

template<size_t MaxPacketSize = 512>
constexpr corium::net::StaticUdpChannel< MaxPacketSize >::StaticUdpChannel ( )
constexprdefaultnoexcept

◆ ~StaticUdpChannel()

template<size_t MaxPacketSize = 512>
corium::net::StaticUdpChannel< MaxPacketSize >::~StaticUdpChannel ( )
inline
+ Here is the call graph for this function:

◆ StaticUdpChannel() [2/3]

template<size_t MaxPacketSize = 512>
corium::net::StaticUdpChannel< MaxPacketSize >::StaticUdpChannel ( const StaticUdpChannel< MaxPacketSize > &  )
delete

◆ StaticUdpChannel() [3/3]

template<size_t MaxPacketSize = 512>
corium::net::StaticUdpChannel< MaxPacketSize >::StaticUdpChannel ( StaticUdpChannel< MaxPacketSize > &&  other)
inlinenoexcept

Member Function Documentation

◆ close()

template<size_t MaxPacketSize = 512>
void corium::net::StaticUdpChannel< MaxPacketSize >::close ( )
inlinenoexcept

Close underlying socket.

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

◆ isOpen()

template<size_t MaxPacketSize = 512>
bool corium::net::StaticUdpChannel< MaxPacketSize >::isOpen ( ) const
inlinenoexcept

Returns true if socket is open and bound.

◆ nativeHandle()

template<size_t MaxPacketSize = 512>
int corium::net::StaticUdpChannel< MaxPacketSize >::nativeHandle ( ) const
inlinenoexcept

Native socket file descriptor or handle.

◆ openAndBind()

template<size_t MaxPacketSize = 512>
bool corium::net::StaticUdpChannel< MaxPacketSize >::openAndBind ( uint16_t  port = 0,
const char *  ip = "0.0.0.0" 
)
inlinenoexcept

Open UDP socket and bind to a local port and IP address.

Parameters
portLocal port to bind to (0 for ephemeral).
ipLocal interface IP address (default: "0.0.0.0").
Returns
true if socket was created and bound successfully.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [1/2]

template<size_t MaxPacketSize = 512>
StaticUdpChannel & corium::net::StaticUdpChannel< MaxPacketSize >::operator= ( const StaticUdpChannel< MaxPacketSize > &  )
delete

◆ operator=() [2/2]

template<size_t MaxPacketSize = 512>
StaticUdpChannel & corium::net::StaticUdpChannel< MaxPacketSize >::operator= ( StaticUdpChannel< MaxPacketSize > &&  other)
inlinenoexcept
+ Here is the call graph for this function:

◆ receive()

template<size_t MaxPacketSize = 512>
bool corium::net::StaticUdpChannel< MaxPacketSize >::receive ( std::span< uint8_t >  bufferOut,
size_t &  bytesReceivedOut 
)
inlinenoexcept

Receive raw bytes from incoming UDP datagram.

Parameters
bufferOutOutput buffer.
bytesReceivedOutNumber of bytes received.
Returns
true if datagram was received.
+ Here is the caller graph for this function:

◆ receiveAndPush()

template<size_t MaxPacketSize = 512>
template<typename EventVariant , typename Sink >
bool corium::net::StaticUdpChannel< MaxPacketSize >::receiveAndPush ( Sink &  sink,
EventPriority  priority = EventPriority::Normal 
)
inlinenoexcept

Receive a WirePacket and deserialize directly into a Corium EventSink.

Template Parameters
EventVariantVariant list of all supported events.
SinkTarget EventSink or EventBus.
Parameters
sinkTarget sink.
priorityPriority to assign to the deserialized event.
Returns
true if a valid event packet was received and pushed into sink.
+ Here is the call graph for this function:

◆ sendEvent()

template<size_t MaxPacketSize = 512>
template<typename Event , typename EventVariant >
bool corium::net::StaticUdpChannel< MaxPacketSize >::sendEvent ( const char *  ip,
uint16_t  port,
const Event event 
)
inlinenoexcept

Serialize and send a typed event over UDP using Corium WirePacket framing.

Template Parameters
EventConcrete event type (must be trivially copyable).
EventVariantVariant list for type indexing.
Parameters
ipTarget IPv4 address.
portTarget port.
eventEvent instance to transmit.
Returns
true if packet was serialized and sent.
+ Here is the call graph for this function:

◆ sendTo()

template<size_t MaxPacketSize = 512>
bool corium::net::StaticUdpChannel< MaxPacketSize >::sendTo ( const char *  ip,
uint16_t  port,
std::span< const uint8_t >  data 
)
inlinenoexcept

Send raw payload to target UDP endpoint.

Parameters
ipTarget IPv4 address string (e.g. "127.0.0.1").
portTarget port.
dataByte payload to transmit.
Returns
true if datagram was sent successfully.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setNonBlocking()

template<size_t MaxPacketSize = 512>
bool corium::net::StaticUdpChannel< MaxPacketSize >::setNonBlocking ( bool  nonBlocking = true)
inlinenoexcept

Set socket non-blocking mode.

Parameters
nonBlockingtrue for non-blocking I/O.
Returns
true on success.

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