This is a set of tutorials about working with asynchronous I/O in C++ which is in turn mainly deals with networking. To go smoothly you should be familiar with modern C++, STL- and Boost-style coding, as well as basic networking and multithreading principles.
We will use Boost.Asio, Boost.Beast, and (or) C++20 Networking library. To achieve asynchronous control flow we will use completion handlers, coroutines or fibers.
To compile a source code from the given examples you will need C++17 compiler and Boost libraries installed. You need to add Boost libraries into include directories and link your application against its compiled source code.
In fact, for the most of examples all you need is to compile
boost/libs/system/src/error_code.cpp — the rest of Boost source code you need are header-only libraries, ta-da!
Networking is usually considered as a tricky subject by those who're just starting to learn it. Is it really so tricky? Well, the answer is yes and no. It will take time to become an expert, however I'll try to keep things as simple as possible to let you start smoothly.
In real life you should use namespace and type aliases to keep things neat. I'll start to do this a bit later, after you have a clear understanding where do things come from. So you'll see things like
boost::asio::ip::tcp::socket which in your production code should be aliased as something like
Two big fishes of networking are clients and servers. Tutorial authors usually start from the client since it's considered as a lesser fish. I will start with the servers instead. First — because servers are the area where C++ does really shine. Second — it's not in fact as scary as it appear to be.
OK, done with introductions, let's get started!