SOIL C++
C++ Unified Device Interface
|
#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... | |
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.
UDP::Broadcast::Broadcast | ( | int | n_threads = 1 | ) |
Constructor instantiating an UDP Broadcast. The socket is immediately opened upon successful construction.
[in] | n_threads | Number 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.
UDP::Broadcast::~Broadcast | ( | ) |
Destructor which closes the socket and stops all threads if not previously done.
Definition at line 23 of file Broadcast.cpp.
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.
[in] | ip | IPv4 address to send to |
[in] | port | Port to send to |
Definition at line 40 of file Broadcast.cpp.
void UDP::Broadcast::configure | ( | UDP::Configuration | config | ) |
Configure the broadcast with a configuration object, i.e. a list of endpoints.
[in] | config | Configuration object |
Definition at line 132 of file Broadcast.cpp.
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.
[in] | ip | IPv4 adress of the client to remove |
Definition at line 63 of file Broadcast.cpp.
void UDP::Broadcast::send | ( | std::string | message | ) |
Send an individual message over the UDP Broadcast.It will be terminated by a newline (\r
).
[in] | message | Message to send |
Definition at line 109 of file Broadcast.cpp.
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
).
[in] | messages | Messages to send |
Definition at line 114 of file Broadcast.cpp.
|
inline |
Get the number of registered UDP clients.
Definition at line 139 of file Broadcast.h.