| 31 | } |
| 32 | |
| 33 | awaitable<void> echo(tcp::socket socket) |
| 34 | { |
| 35 | try |
| 36 | { |
| 37 | for (;;) |
| 38 | { |
| 39 | // The asynchronous operations to echo a single chunk of data have been |
| 40 | // refactored into a separate function. When this function is called, the |
| 41 | // operations are still performed in the context of the current |
| 42 | // coroutine, and the behaviour is functionally equivalent. |
| 43 | co_await echo_once(socket); |
| 44 | } |
| 45 | } |
| 46 | catch (std::exception& e) |
| 47 | { |
| 48 | std::printf("echo Exception: %s\n", e.what()); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | awaitable<void> listener() |
| 53 | { |