14 #include <boost/asio.hpp> 25 const std::string multicast_address_str =
"224.0.0.1";
26 const short multicast_port = 10002;
27 const int max_message_count = 10;
30 boost::asio::io_context io_context;
31 boost::asio::steady_timer my_timer(io_context);
34 for (
int i = 0; i < max_message_count; i++) {
35 std::string msg =
"Menssagem " + std::to_string(i);
36 size_t bytes_sent = my_sender.
send(msg.c_str(), msg.length());
38 std::cout << msg <<
"\nBytes sent: " << bytes_sent <<
"\n\n";
40 my_timer.expires_after(std::chrono::milliseconds(200));
43 }
catch (std::exception& e) {
44 std::cerr <<
"Exception: " << e.what() <<
"\n";
Sender class using UDP in multicast mode.
size_t send(const char *buffer, const size_t buffer_size)
Send data using UDP.
Send data using UDP in multicast mode.