| 18 | char read_buffer[1024]; |
| 19 | |
| 20 | void read_handler(const boost::system::error_code& e, |
| 21 | std::size_t bytes_transferred, tcp::socket* s) |
| 22 | { |
| 23 | if (!e) |
| 24 | { |
| 25 | std::cout.write(read_buffer, bytes_transferred); |
| 26 | |
| 27 | s->async_read_some(boost::asio::buffer(read_buffer), |
| 28 | std::bind(read_handler, boost::asio::placeholders::error, |
| 29 | boost::asio::placeholders::bytes_transferred, s)); |
| 30 | } |
| 31 | else |
| 32 | { |
| 33 | boost::asio::execution_context& context = boost::asio::query( |
| 34 | s->get_executor(), boost::asio::execution::context); |
| 35 | services::logger logger(context, "read_handler"); |
| 36 | |
| 37 | std::string msg = "Read error: "; |
| 38 | msg += e.message(); |
| 39 | logger.log(msg); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | void connect_handler(const boost::system::error_code& e, tcp::socket* s) |
| 44 | { |
nothing calls this directly
no test coverage detected