42 using boost::asio::ip::tcp;
48 Comm(message_handler),
71 endpoint_ = *resolver.resolve({tcp::v4(),
host_,
"", boost::asio::ip::resolver_query_base::numeric_service});
77 socket_.set_option(tcp::socket::reuse_address(
true));
81 catch (boost::system::system_error e)
96 boost::function<
void(
const boost::system::error_code&,
size_t)> handler)
98 socket_.async_receive(buffer, handler);
102 boost::function<
void(
const boost::system::error_code&,
size_t)> handler)
104 socket_.async_send(buffer, handler);
void do_async_read(const boost::asio::mutable_buffers_1 &buffer, boost::function< void(const boost::system::error_code &, size_t)> handler) override
boost::asio::ip::tcp::socket socket_
static constexpr size_t WRITE_BUFFER_SIZE
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
void do_async_write(const boost::asio::const_buffers_1 &buffer, boost::function< void(const boost::system::error_code &, size_t)> handler) override
TCPClient(std::string host=DEFAULT_HOST, uint16_t port=DEFAULT_PORT, MessageHandler &message_handler=default_message_handler_)
Connect to a TCP socket as a client.
static constexpr size_t READ_BUFFER_SIZE
Abstract base class for message handler.
boost::asio::ip::tcp::endpoint endpoint_