MCPcopy Create free account
hub / github.com/boostorg/asio / echo

Function echo

example/cpp20/coroutines/echo_server_with_deferred.cpp:27–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25namespace this_coro = boost::asio::this_coro;
26
27awaitable<void> echo(tcp::socket socket)
28{
29 try
30 {
31 char data[1024];
32 for (;;)
33 {
34 std::size_t n = co_await socket.async_read_some(boost::asio::buffer(data), deferred);
35 co_await async_write(socket, boost::asio::buffer(data, n), deferred);
36 }
37 }
38 catch (std::exception& e)
39 {
40 std::printf("echo Exception: %s\n", e.what());
41 }
42}
43
44awaitable<void> listener()
45{

Callers 1

listenerFunction · 0.70

Calls 3

bufferFunction · 0.85
async_writeFunction · 0.85
async_read_someMethod · 0.45

Tested by

no test coverage detected