| 106 | } |
| 107 | |
| 108 | std::size_t AsioTransport::receive(std::span<std::byte> dst) { |
| 109 | bool done = false; |
| 110 | asio::error_code op_ec; |
| 111 | std::size_t n = 0; |
| 112 | socket_.async_read_some( |
| 113 | asio::buffer(dst.data(), dst.size()), |
| 114 | [&op_ec, &n, &done](const asio::error_code& e, std::size_t got) { |
| 115 | op_ec = e; |
| 116 | n = got; |
| 117 | done = true; |
| 118 | }); |
| 119 | if (run_until(*ctx_, socket_, done, timeout_)) { |
| 120 | throw_socket_timeout_error("read"); |
| 121 | } |
| 122 | if (op_ec) { |
| 123 | // EOF/error -> read_impl escalates the 0 to a timeout. |
| 124 | disconnected_ = true; |
| 125 | return 0; |
| 126 | } |
| 127 | return n; |
| 128 | } |
| 129 | |
| 130 | bool AsioTransport::has_data() const { |
| 131 | asio::error_code ec; |
no test coverage detected