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 bind_host_(bind_host),
51 bind_port_(bind_port),
52 remote_host_(remote_host),
53 remote_port_(remote_port),
83 socket_.set_option(udp::socket::reuse_address(
true));
87 catch (boost::system::system_error e)
89 std::cerr << e.what() << std::endl;
102 boost::function<
void(
const boost::system::error_code&,
size_t)> handler)
108 boost::function<
void(
const boost::system::error_code&,
size_t)> handler)
boost::asio::ip::udp::endpoint bind_endpoint_
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.
boost::asio::ip::udp::endpoint remote_endpoint_
static constexpr size_t READ_BUFFER_SIZE
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)
Bind a UDP socket.
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