38 #ifndef ASYNC_COMM_TCP_CLIENT_H 39 #define ASYNC_COMM_TCP_CLIENT_H 43 #include <boost/asio.hpp> 44 #include <boost/function.hpp> 65 TCPClient(std::string host = DEFAULT_HOST, uint16_t port = DEFAULT_PORT,
70 static constexpr
auto DEFAULT_HOST =
"localhost";
71 static constexpr uint16_t DEFAULT_PORT = 16140;
73 bool is_open()
override;
74 bool do_init()
override;
75 void do_close()
override;
76 void do_async_read(
const boost::asio::mutable_buffers_1 &buffer,
77 boost::function<
void(
const boost::system::error_code&,
size_t)> handler)
override;
78 void do_async_write(
const boost::asio::const_buffers_1 &buffer,
79 boost::function<
void(
const boost::system::error_code&,
size_t)> handler)
override;
84 boost::asio::ip::tcp::socket socket_;
85 boost::asio::ip::tcp::endpoint endpoint_;
90 #endif // ASYNC_COMM_TCP_CLIENT_H
Abstract base class for an asynchronous communication port.
Asynchronous communication class for a TCP client.
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.
Abstract base class for message handler.