Skip to content

Class nebula::drivers::connections::UdpSocket

ClassList > nebula > drivers > connections > UdpSocket

  • #include <udp.hpp>

Classes

Type Name
class Builder
struct PerfCounters
struct RxMetadata

Public Types

Type Name
typedef std::function< void(std::vector< uint8_t > &data, const RxMetadata &metadata)> callback_t
typedef util::thread_factory_t thread_factory_t

Public Functions

Type Name
UdpSocket (const UdpSocket &) = delete
UdpSocket (UdpSocket && other) noexcept
bool is_subscribed ()
UdpSocket & operator= (const UdpSocket &) = delete
UdpSocket & operator= (UdpSocket &&) = delete
void send (const std::vector< uint8_t > & data)
Send a datagram to the destination set in set_send_destination() .
UdpSocket & subscribe (callback_t && callback, thread_factory_t thread_factory=util::StdThreadFactory{})
Register a callback for processing received packets and start the receiver thread. The callback will be called for each received packet, and will be executed in the receive thread. Has to be called on a bound socket ( bind() has to have been called before).
UdpSocket & unsubscribe ()
Gracefully stops the active receiver thread (if any) but keeps the socket alive. The same socket can later be subscribed again.
~UdpSocket ()

Public Types Documentation

typedef callback_t

using nebula::drivers::connections::UdpSocket::callback_t =  std::function<void(std::vector<uint8_t> & data, const RxMetadata & metadata)>;

typedef thread_factory_t

using nebula::drivers::connections::UdpSocket::thread_factory_t =  util::thread_factory_t;

Creates the receiver thread from a given thread body. Note: the factory is invoked again each time the receiver thread is relaunched, i.e. when a subscribed socket is re-subscribed or moved (the previous thread is joined first, so two factory-created threads never coexist).


Public Functions Documentation

function UdpSocket [2/3]

nebula::drivers::connections::UdpSocket::UdpSocket (
    const UdpSocket &
) = delete

function UdpSocket [3/3]

inline nebula::drivers::connections::UdpSocket::UdpSocket (
    UdpSocket && other
) noexcept

function is_subscribed

inline bool nebula::drivers::connections::UdpSocket::is_subscribed () 

function operator=

UdpSocket & nebula::drivers::connections::UdpSocket::operator= (
    const UdpSocket &
) = delete

function operator=

UdpSocket & nebula::drivers::connections::UdpSocket::operator= (
    UdpSocket &&
) = delete

function send

Send a datagram to the destination set in set_send_destination() .

inline void nebula::drivers::connections::UdpSocket::send (
    const std::vector< uint8_t > & data
) 

Parameters:

  • data The data to send

Exception:

  • UsageError If no destination has been set via set_send_destination()
  • SocketError If the send operation fails

function subscribe

Register a callback for processing received packets and start the receiver thread. The callback will be called for each received packet, and will be executed in the receive thread. Has to be called on a bound socket ( bind() has to have been called before).

inline UdpSocket & nebula::drivers::connections::UdpSocket::subscribe (
    callback_t && callback,
    thread_factory_t thread_factory=util::StdThreadFactory {}
) 

Parameters:

  • callback The function to be executed for each received packet.
  • thread_factory The factory used to create the receiver thread. Must not be null.

function unsubscribe

Gracefully stops the active receiver thread (if any) but keeps the socket alive. The same socket can later be subscribed again.

inline UdpSocket & nebula::drivers::connections::UdpSocket::unsubscribe () 


function ~UdpSocket

inline nebula::drivers::connections::UdpSocket::~UdpSocket () 


The documentation for this class was generated from the following file src/nebula_core/nebula_core_hw_interfaces/include/nebula_core_hw_interfaces/connections/udp.hpp