38 #ifndef ASYNC_COMM_UDP_H 39 #define ASYNC_COMM_UDP_H 43 #include <boost/asio.hpp> 44 #include <boost/function.hpp> 67 UDP(std::string bind_host = DEFAULT_BIND_HOST, uint16_t bind_port = DEFAULT_BIND_PORT,
68 std::string remote_host = DEFAULT_REMOTE_HOST, uint16_t remote_port = DEFAULT_REMOTE_PORT,
73 static constexpr
auto DEFAULT_BIND_HOST =
"localhost";
74 static constexpr uint16_t DEFAULT_BIND_PORT = 16140;
75 static constexpr
auto DEFAULT_REMOTE_HOST =
"localhost";
76 static constexpr uint16_t DEFAULT_REMOTE_PORT = 16145;
78 bool is_open()
override;
79 bool do_init()
override;
80 void do_close()
override;
81 void do_async_read(
const boost::asio::mutable_buffers_1 &buffer,
82 boost::function<
void(
const boost::system::error_code&,
size_t)> handler)
override;
83 void do_async_write(
const boost::asio::const_buffers_1 &buffer,
84 boost::function<
void(
const boost::system::error_code&,
size_t)> handler)
override;
86 std::string bind_host_;
89 std::string remote_host_;
90 uint16_t remote_port_;
92 boost::asio::ip::udp::socket socket_;
93 boost::asio::ip::udp::endpoint bind_endpoint_;
94 boost::asio::ip::udp::endpoint remote_endpoint_;
99 #endif // ASYNC_COMM_UDP_H
UDP(std::string bind_host=DEFAULT_BIND_HOST, uint16_t bind_port=DEFAULT_BIND_PORT, std::string remote_host=DEFAULT_REMOTE_HOST, uint16_t remote_port=DEFAULT_REMOTE_PORT, MessageHandler &message_handler=default_message_handler_)
Bind a UDP socket.
Abstract base class for an asynchronous communication port.
Abstract base class for message handler.
Asynchronous communication class for a UDP socket.