en	Examples

en	Source code and build scripts for these programs are located in the [path_link example example] directory.

en	Clients

en	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.

en	HTTP, synchronous

en	[path_link example/http/client/sync/http_client_sync.cpp http_client_sync.cpp]

en	[path_link example/http/client/sync-ssl/http_client_sync_ssl.cpp http_client_sync_ssl.cpp]

en	HTTP, asynchronous

en	[path_link example/http/client/async/http_client_async.cpp http_client_async.cpp]

en	[path_link example/http/client/async-ssl/http_client_async_ssl.cpp http_client_async_ssl.cpp]

en	HTTP, asynchronous Unix domain sockets

en	[path_link example/http/client/async-local/http_client_async_local.cpp http_client_async_local.cpp]

en	HTTP, asynchronous using __system_executor__

en	[path_link example/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp http_client_async_ssl_system_executor.cpp]

en	HTTP, coroutine

en	[path_link example/http/client/coro/http_client_coro.cpp http_client_coro.cpp]

en	[path_link example/http/client/coro-ssl/http_client_coro_ssl.cpp http_client_coro_ssl.cpp]

en	HTTP, C++20 coroutine

en	[path_link example/http/client/awaitable/http_client_awaitable.cpp http_client_awaitable.cpp]

en	[path_link example/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp http_client_awaitable_ssl.cpp]

en	HTTP crawl (asynchronous)

en	[path_link example/http/client/crawl/http_crawl.cpp http_crawl.cpp]

en	HTTP json_body (synchronous)

en	[path_link example/http/client/body/json_body.hpp json_body.hpp] [path_link example/http/client/body/json_client.cpp json_client.cpp]

en	HTTP client for all methods (synchronous)

en	[path_link example/http/client/methods/http_client_methods.cpp http_client_methods.cpp]

en	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.

en	WebSocket, synchronous

en	[path_link example/websocket/client/sync/websocket_client_sync.cpp websocket_client_sync.cpp]

en	[path_link example/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp websocket_client_sync_ssl.cpp]

en	WebSocket, asynchronous

en	[path_link example/websocket/client/async/websocket_client_async.cpp websocket_client_async.cpp]

en	[path_link example/websocket/client/async-ssl/websocket_client_async_ssl.cpp websocket_client_async_ssl.cpp]

en	WebSocket, asynchronous Unix domain sockets

en	[path_link example/websocket/client/async-local/websocket_client_async_local.cpp websocket_client_async_local.cpp]

en	WebSocket, asynchronous using __system_executor__

en	[path_link example/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp websocket_client_async_ssl_system_executor.cpp]

en	WebSocket, coroutine

en	[path_link example/websocket/client/coro/websocket_client_coro.cpp websocket_client_coro.cpp]

en	[path_link example/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp websocket_client_coro_ssl.cpp]

en	WebSocket, C++20 coroutine

en	[path_link example/websocket/client/awaitable/websocket_client_awaitable.cpp websocket_client_awaitable.cpp]

en	Servers

en	These HTTP servers deliver files from a root directory specified on the command line. All asynchronous servers support timeouts.

en	HTTP, synchronous

en	[path_link example/http/server/sync/http_server_sync.cpp http_server_sync.cpp]

en	[path_link example/http/server/sync-ssl/http_server_sync_ssl.cpp http_server_sync_ssl.cpp]

en	HTTP, asynchronous

en	[path_link example/http/server/async/http_server_async.cpp http_server_async.cpp]

en	[path_link example/http/server/async-ssl/http_server_async_ssl.cpp http_server_async_ssl.cpp]

en	HTTP, asynchronous Unix domain sockets

en	[path_link example/http/server/async-local/http_server_async_local.cpp http_server_async_local.cpp]

en	HTTP, coroutine

en	[path_link example/http/server/coro/http_server_coro.cpp http_server_coro.cpp]

en	[path_link example/http/server/coro-ssl/http_server_coro_ssl.cpp http_server_coro_ssl.cpp]

en	HTTP, stackless coroutine

en	[path_link example/http/server/stackless/http_server_stackless.cpp http_server_stackless.cpp]

en	[path_link example/http/server/stackless-ssl/http_server_stackless_ssl.cpp http_server_stackless_ssl.cpp]

en	HTTP, C++ 20 coroutine

en	[path_link example/http/server/awaitable/http_server_awaitable.cpp http_server_awaitable.cpp]

en	HTTP, fast (optimized for speed)

en	[path_link example/http/server/fast/http_server_fast.cpp http_server_fast.cpp]

en	HTTP, small (optimized for space)

en	[path_link example/http/server/small/http_server_small.cpp http_server_small.cpp]

en	HTTP, flex (plain + SSL)

en	[path_link example/http/server/flex/http_server_flex.cpp http_server_flex.cpp]

en	These WebSocket servers echo back any message received, keeping the session open until the client disconnects. All asynchronous servers support timeouts.

en	WebSocket, synchronous

en	[path_link example/websocket/server/sync/websocket_server_sync.cpp websocket_server_sync.cpp]

en	[path_link example/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp websocket_server_sync_ssl.cpp]

en	WebSocket, asynchronous

en	[path_link example/websocket/server/async/websocket_server_async.cpp websocket_server_async.cpp]

en	[path_link example/websocket/server/async-ssl/websocket_server_async_ssl.cpp websocket_server_async_ssl.cpp]

en	WebSocket, asynchronous Unix domain sockets

en	[path_link example/websocket/server/async-local/websocket_server_async_local.cpp websocket_server_async_local.cpp]

en	WebSocket, coroutine

en	[path_link example/websocket/server/coro/websocket_server_coro.cpp websocket_server_coro.cpp]

en	[path_link example/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp websocket_server_coro_ssl.cpp]

en	WebSocket, stackless coroutine

en	[path_link example/websocket/server/stackless/websocket_server_stackless.cpp websocket_server_stackless.cpp]

en	[path_link example/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp websocket_server_stackless_ssl.cpp]

en	WebSocket, C++ 20 coroutine

en	[path_link example/websocket/server/awaitable/websocket_server_awaitable.cpp websocket_server_awaitable.cpp]

en	WebSocket, fast (suited for benchmarks)

en	[path_link example/websocket/server/fast/websocket_server_fast.cpp websocket_server_fast.cpp]

en	Servers (Advanced)

en	These servers offer both HTTP and WebSocket services on the same port, and illustrate the implementation of advanced features.

en	Advanced

en	[itemized_list [Timeouts] [Multi-threaded] [HTTP pipelining] [Parser-oriented HTTP reading] [Dual protocols: HTTP and WebSocket] [Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)] ]

en	[path_link example/advanced/server/advanced_server.cpp advanced_server.cpp]

en	Advanced, flex (plain + SSL)

en	[itemized_list [Timeouts] [Multi-threaded] [HTTP pipelining] [Parser-oriented HTTP reading] [Dual protocols: HTTP and WebSocket] [Flexible ports: plain and SSL on the same port] [Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)] ]

en	[path_link example/advanced/server-flex/advanced_server_flex.cpp advanced_server_flex.cpp]

en	Advanced, flex (plain + SSL) with awaitable

en	[itemized_list [Timeouts] [Multi-threaded] [HTTP pipelining] [Parser-oriented HTTP reading] [Dual protocols: HTTP and WebSocket] [Flexible ports: plain and SSL on the same port] [Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)] [Usage of cancellation_signals] ]

en	[path_link example/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp advanced_server_flex_awaitable.cpp]

en	Chat Server, multi-threaded

en	[itemized_list [Multi-threaded] [Broadcasting Messages] [Multi-user Chat Server] [JavaScript Browser Client] [Parser-oriented HTTP reading] [Dual protocols: HTTP and WebSocket] [Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)] ]

en	[path_link example/websocket/server/chat-multi chat-multi]

en	Chat Server __video__

en	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 [@https://cppcon.org CppCon 2018]. The source code in the Beast example contains improvements to the original program.

en	Chat WebSocket Server and JavaScript Client

en	Component

en	Features

en	Sources

en	Server

en	[itemized_list [C++] [Timeouts] [Multi-threaded] [Broadcast to multiple peers] [Dual protocols: HTTP and WebSocket] [Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)] ]

en	[path_link example/websocket/server/chat-multi chat-multi]

en	Client

en	[itemized_list [JavaScript / HTML5] [Runs in the browser] [Delivered by the server] [Only 60 lines total including UI] [Completely portable graphics] ]

en	[path_link example/websocket/server/chat-multi/chat_client.html chat_client.html]