SOIL C++
C++ Unified Device Interface
UDP::Broadcast Class Reference

UDP Broadcast. More...

#include <Broadcast.h>

Public Member Functions

 Broadcast (int n_threads=1)
 Constructor. More...
 
 ~Broadcast ()
 Destructor. More...
 
void add_client (std::string ip, unsigned int port)
 Add UDP client. More...
 
void remove_client (std::string ip)
 Remove UDP client. More...
 
void send (std::string message)
 Send Message. More...
 
void send (std::vector< std::string > messages)
 Send Multiple Message. More...
 
int use_count (void)
 Number of Clients. More...
 
void configure (UDP::Configuration config)
 Configure Broadcast. More...
 

Detailed Description

Simple UDP Broadcast implemented on top of boost asio. This is currently a conveience member of the C++ SOIL library as its not part of the specification. It may be omitted in the future.

Definition at line 22 of file Broadcast.h.

Constructor & Destructor Documentation

◆ Broadcast()

UDP::Broadcast::Broadcast ( int  n_threads = 1)

Constructor instantiating an UDP Broadcast. The socket is immediately opened upon successful construction.

Parameters
[in]n_threadsNumber of threads to assign to the thread group. Only for very large loads a number of threads greater than 1 should be needed.

Definition at line 5 of file Broadcast.cpp.

◆ ~Broadcast()

UDP::Broadcast::~Broadcast ( )

Destructor which closes the socket and stops all threads if not previously done.

Definition at line 23 of file Broadcast.cpp.

Member Function Documentation

◆ add_client()

void UDP::Broadcast::add_client ( std::string  ip,
unsigned int  port 
)

Add a client to list of recipients of the UDP broadcast. One can only send to one port per IP address, the IPv4 address acts as unique identifier.

Parameters
[in]ipIPv4 address to send to
[in]portPort to send to

Definition at line 40 of file Broadcast.cpp.

◆ configure()

void UDP::Broadcast::configure ( UDP::Configuration  config)

Configure the broadcast with a configuration object, i.e. a list of endpoints.

Parameters
[in]configConfiguration object

Definition at line 132 of file Broadcast.cpp.

◆ remove_client()

void UDP::Broadcast::remove_client ( std::string  ip)

Remove a client to list of recipients of the UDP broadcast which is identified through its IPv4 address.

Parameters
[in]ipIPv4 adress of the client to remove

Definition at line 63 of file Broadcast.cpp.

◆ send() [1/2]

void UDP::Broadcast::send ( std::string  message)

Send an individual message over the UDP Broadcast.It will be terminated by a newline (\r
).

Parameters
[in]messageMessage to send

Definition at line 109 of file Broadcast.cpp.

◆ send() [2/2]

void UDP::Broadcast::send ( std::vector< std::string >  messages)

Send a set of messages over the UDP Broadcast.They will be separated and terminated by a newlines (\r
).

Parameters
[in]messagesMessages to send

Definition at line 114 of file Broadcast.cpp.

◆ use_count()

int UDP::Broadcast::use_count ( void  )
inline

Get the number of registered UDP clients.

Returns
Number of registered UDP clients.

Definition at line 139 of file Broadcast.h.


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