multicast_tx_socket.hpp
1 // SPDX-FileCopyrightText: Copyright (C) 2025 Marek Küthe <m.k@mk16.de> 2 // 3 // SPDX-License-Identifier: GPL-3.0-or-later 4 5 #ifndef MULTICAST_TX_SOCKET 6 #define MULTICAST_TX_SOCKET 7 8 #include <functional> 9 #include <memory> 10 #include <utility> 11 #include <boost/asio.hpp> 12 #include <boost/log/trivial.hpp> 13 #include "posix_wrapper.hpp" 14 15 namespace MPingSender 16 { 17 class MulticastTxSocket 18 { 19 public: 20 explicit MulticastTxSocket( 21 boost::asio::any_io_executor ex, 22 std::function<void(boost::system::error_code)> error_handler, 23 const boost::asio::ip::udp::endpoint& endpoint, 24 const boost::asio::ip::multicast::hops hops, 25 const std::string& interface); 26 27 void send_packet(const std::string& message, 28 const boost::asio::ip::udp::endpoint endpoint); 29 30 private: 31 boost::asio::ip::udp::socket _socket; 32 std::function<void(boost::system::error_code)> _error_handler; 33 }; 34 } // namespace MPingSender 35 36 #endif