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

Function echo

example/cpp20/coroutines/echo_server.cpp:31–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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