diff --git a/asio/src/examples/cpp17/coroutines_ts/chat_server.cpp b/asio/src/examples/cpp17/coroutines_ts/chat_server.cpp index b6c918b2..43622502 100644 --- a/asio/src/examples/cpp17/coroutines_ts/chat_server.cpp +++ b/asio/src/examples/cpp17/coroutines_ts/chat_server.cpp @@ -204,7 +204,10 @@ int main(int argc, char* argv[]) { unsigned short port = std::atoi(argv[i]); co_spawn(io_context, - [&]{ return listener(tcp::acceptor(io_context, {tcp::v4(), port})); }, + [&io_context, port] + { + return listener(tcp::acceptor(io_context, {tcp::v4(), port})); + }, detached); }