| 99 | } |
| 100 | |
| 101 | void do_write() |
| 102 | { |
| 103 | boost::asio::async_write(socket_, |
| 104 | boost::asio::buffer(write_msgs_.front().data(), |
| 105 | write_msgs_.front().length()), |
| 106 | [this](boost::system::error_code ec, std::size_t /*length*/) |
| 107 | { |
| 108 | if (!ec) |
| 109 | { |
| 110 | write_msgs_.pop_front(); |
| 111 | if (!write_msgs_.empty()) |
| 112 | { |
| 113 | do_write(); |
| 114 | } |
| 115 | } |
| 116 | else |
| 117 | { |
| 118 | socket_.close(); |
| 119 | } |
| 120 | }); |
| 121 | } |
| 122 | |
| 123 | private: |
| 124 | boost::asio::io_context& io_context_; |