...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Source code and build scripts for these programs are located in the example directory.
These HTTP clients submit a GET request to a server specified on the command line, and prints the resulting response. The crawl client asynchronously fetches the document root of the 10,000 top ranked domains, this may be used to evaluate robustness. All asynchronous clients support timeouts.
Description |
Source File |
Source File (using SSL) |
---|---|---|
HTTP, synchronous |
||
HTTP, asynchronous |
||
HTTP, asynchronous using |
||
HTTP, coroutine |
||
WebSocket, C++20 coroutine |
||
HTTP crawl (asynchronous) |
||
HTTP json_body (synchronous) |
||
HTTP client for all methods (synchronous) |
These WebSocket clients connect to a server and send a message, then receive a message and print the response before disconnecting. All asynchronous clients support timeouts.
Description |
Source File |
Source File (using SSL) |
---|---|---|
WebSocket, synchronous |
||
WebSocket, asynchronous |
||
WebSocket, asynchronous using |
||
WebSocket, coroutine |
||
WebSocket, C++20 coroutine |
These HTTP servers deliver files from a root directory specified on the command line. All asynchronous servers support timeouts.
Description |
Source File |
Source File (using SSL) |
---|---|---|
HTTP, synchronous |
||
HTTP, asynchronous |
||
HTTP, coroutine |
||
HTTP, stackless coroutine |
||
HTTP, C++ 20 coroutine |
||
HTTP, fast (optimized for speed) |
||
HTTP, small (optimized for space) |
||
HTTP, flex (plain + SSL) |
These WebSocket servers echo back any message received, keeping the session open until the client disconnects. All asynchronous servers support timeouts.
Description |
Source File |
Source File (using SSL) |
---|---|---|
WebSocket, synchronous |
||
WebSocket, asynchronous |
||
WebSocket, coroutine |
||
WebSocket, stackless coroutine |
||
WebSocket, C++ 20 coroutine |
||
WebSocket, fast (suited for benchmarks) |
These servers offer both HTTP and WebSocket services on the same port, and illustrate the implementation of advanced features.
Description |
Features |
Sources |
---|---|---|
Advanced |
|
|
Advanced, flex (plain + SSL) |
|
|
Advanced, flex (plain + SSL) with awaitable |
|
|
Chat Server, multi-threaded |
|
This example demonstrates a websocket chat server, allowing multiple users to connect and participate in live, group messaging. It comes with a tiny front end implemented in JavaScript and HTML5 which runs in any browser. The example is accompanied by a one hour presentation which provides a discussion of networking concepts, followed by in-depth explanation of how the client and server are constructed. This talk was delivered at CppCon 2018. The source code in the Beast example contains improvements to the original program.
Table 1.1. Chat WebSocket Server and JavaScript Client
Component |
Features |
Sources |
---|---|---|
Server |
|
|
Client |
|