42 using boost::asio::ip::udp;
48 UDP::UDP(std::string bind_host, uint16_t bind_port, std::string remote_host, uint16_t remote_port,
50 Comm(message_handler),
51 bind_host_(bind_host),
52 bind_port_(bind_port),
53 remote_host_(remote_host),
54 remote_port_(remote_port),
76 boost::asio::ip::resolver_query_base::numeric_service});
80 boost::asio::ip::resolver_query_base::numeric_service});
86 socket_.set_option(udp::socket::reuse_address(
true));
90 catch (boost::system::system_error e)
105 boost::function<
void(
const boost::system::error_code&,
size_t)> handler)
111 boost::function<
void(
const boost::system::error_code&,
size_t)> handler)
boost::asio::ip::udp::endpoint bind_endpoint_
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.
static constexpr size_t WRITE_BUFFER_SIZE
boost::asio::ip::udp::socket socket_
boost::asio::io_service io_service_
Abstract base class for an asynchronous communication port.
MessageHandler & message_handler_
virtual void error(const std::string &message)=0
boost::asio::ip::udp::endpoint remote_endpoint_
static constexpr size_t READ_BUFFER_SIZE
Abstract base class for message handler.
void do_async_read(const boost::asio::mutable_buffers_1 &buffer, boost::function< void(const boost::system::error_code &, size_t)> handler) override
void do_async_write(const boost::asio::const_buffers_1 &buffer, boost::function< void(const boost::system::error_code &, size_t)> handler) override