How to Use C++20 Coroutines for Networking

By Jim Pascoe

This talk shows how to write an event-driven 'chat' program using C++20 coroutines. Coroutines improve the process of writing event-driven code and this talk provides a worked example of how to do so. Practical strategies for how to design, debug and reason about such architectures are given. The talk opens by introducing a familiar callback version of 'chat' that is based on Boost.Asio. The talk then shows how the same application can be coded using C++20 coroutines. The performance of the two approaches is compared empirically and a number of observations are made.