Files
boost_beast/doc/qbk/02_examples/_examples.qbk
T

234 lines
8.9 KiB
Plaintext
Raw Normal View History

2016-09-25 11:19:51 -04:00
[/
2019-02-23 21:00:58 -08:00
Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
2016-09-25 11:19:51 -04:00
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
2017-07-28 19:32:33 -07:00
Official repository: https://github.com/boostorg/beast
2016-09-25 11:19:51 -04:00
]
2017-07-09 20:09:30 -07:00
[section Examples]
2017-06-16 19:27:00 -07:00
[block'''<?dbhtml stop-chunking?>''']
2017-06-19 20:03:05 -07:00
Source code and build scripts for these programs are located
2017-10-26 16:05:50 -07:00
in the [source_file example] directory.
2017-06-16 19:27:00 -07:00
2019-02-23 21:00:58 -08:00
[/-----------------------------------------------------------------------------]
2017-06-16 19:27:00 -07:00
2017-08-08 06:20:24 -07:00
[section Clients]
2017-06-16 19:27:00 -07:00
2017-08-04 19:55:28 -07:00
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
2019-02-19 16:30:05 -08:00
used to evaluate robustness. All asynchronous clients support timeouts.
2017-06-16 19:27:00 -07:00
2017-08-04 19:55:28 -07:00
[table
[[Description] [Source File] [Source File (using SSL)]]
[
[HTTP, synchronous]
[[example_src example/http/client/sync/http_client_sync.cpp http_client_sync.cpp]]
[[example_src example/http/client/sync-ssl/http_client_sync_ssl.cpp http_client_sync_ssl.cpp]]
][
[HTTP, asynchronous]
[[example_src example/http/client/async/http_client_async.cpp http_client_async.cpp]]
[[example_src example/http/client/async-ssl/http_client_async_ssl.cpp http_client_async_ssl.cpp]]
][
[HTTP, coroutine]
[[example_src example/http/client/coro/http_client_coro.cpp http_client_coro.cpp]]
[[example_src example/http/client/coro-ssl/http_client_coro_ssl.cpp http_client_coro_ssl.cpp]]
][
[HTTP crawl (asynchronous)]
[[example_src example/http/client/crawl/http_crawl.cpp http_crawl.cpp]]
[]
]]
2017-06-16 19:27:00 -07:00
2017-08-04 19:55:28 -07:00
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.
2016-09-25 11:19:51 -04:00
2017-08-04 19:55:28 -07:00
[table
[[Description] [Source File] [Source File (using SSL)]]
[
[WebSocket, synchronous]
[[example_src example/websocket/client/sync/websocket_client_sync.cpp websocket_client_sync.cpp]]
[[example_src example/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp websocket_client_sync_ssl.cpp]]
][
[WebSocket, asynchronous]
[[example_src example/websocket/client/async/websocket_client_async.cpp websocket_client_async.cpp]]
[[example_src example/websocket/client/async-ssl/websocket_client_async_ssl.cpp websocket_client_async_ssl.cpp]]
][
[WebSocket, coroutine]
[[example_src example/websocket/client/coro/websocket_client_coro.cpp websocket_client_coro.cpp]]
[[example_src example/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp websocket_client_coro_ssl.cpp]]
]]
2017-08-08 06:20:24 -07:00
[endsect]
2019-02-23 21:00:58 -08:00
[/-----------------------------------------------------------------------------]
2017-08-08 06:20:24 -07:00
[section Servers]
2017-08-04 19:55:28 -07:00
These HTTP servers deliver files from a root directory specified on the
command line. All asynchronous servers support timeouts.
2017-08-04 19:55:28 -07:00
[table
[[Description] [Source File] [Source File (using SSL)]]
[
[HTTP, synchronous]
[[example_src example/http/server/sync/http_server_sync.cpp http_server_sync.cpp]]
[[example_src example/http/server/sync-ssl/http_server_sync_ssl.cpp http_server_sync_ssl.cpp]]
][
[HTTP, asynchronous]
[[example_src example/http/server/async/http_server_async.cpp http_server_async.cpp]]
[[example_src example/http/server/async-ssl/http_server_async_ssl.cpp http_server_async_ssl.cpp]]
][
[HTTP, coroutine]
[[example_src example/http/server/coro/http_server_coro.cpp http_server_coro.cpp]]
[[example_src example/http/server/coro-ssl/http_server_coro_ssl.cpp http_server_coro_ssl.cpp]]
][
[HTTP, stackless coroutine]
[[example_src example/http/server/stackless/http_server_stackless.cpp http_server_stackless.cpp]]
[[example_src example/http/server/stackless-ssl/http_server_stackless_ssl.cpp http_server_stackless_ssl.cpp]]
][
[HTTP, fast (optimized for speed)]
[[example_src example/http/server/fast/http_server_fast.cpp http_server_fast.cpp]]
[]
][
[HTTP, small (optimized for space)]
[[example_src example/http/server/small/http_server_small.cpp http_server_small.cpp]]
[]
][
[HTTP, flex (plain + SSL)]
[]
[[example_src example/http/server/flex/http_server_flex.cpp http_server_flex.cpp]]
]]
2017-08-04 19:55:28 -07:00
These WebSocket servers echo back any message received, keeping the
session open until the client disconnects. All asynchronous servers
support timeouts.
2017-08-04 19:55:28 -07:00
[table
[[Description] [Source File] [Source File (using SSL)]]
[
[WebSocket, synchronous]
[[example_src example/websocket/server/sync/websocket_server_sync.cpp websocket_server_sync.cpp]]
[[example_src example/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp websocket_server_sync_ssl.cpp]]
][
[WebSocket, asynchronous]
[[example_src example/websocket/server/async/websocket_server_async.cpp websocket_server_async.cpp]]
[[example_src example/websocket/server/async-ssl/websocket_server_async_ssl.cpp websocket_server_async_ssl.cpp]]
][
[WebSocket, coroutine]
[[example_src example/websocket/server/coro/websocket_server_coro.cpp websocket_server_coro.cpp]]
[[example_src example/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp websocket_server_coro_ssl.cpp]]
][
[WebSocket, stackless coroutine]
[[example_src example/websocket/server/stackless/websocket_server_stackless.cpp websocket_server_stackless.cpp]]
[[example_src example/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp websocket_server_stackless_ssl.cpp]]
][
[WebSocket, fast (suited for benchmarks)]
[[example_src example/websocket/server/fast/websocket_server_fast.cpp websocket_server_fast.cpp]]
[]
]]
2017-08-08 06:20:24 -07:00
[endsect]
2019-02-23 21:00:58 -08:00
[/-----------------------------------------------------------------------------]
2017-08-08 06:20:24 -07:00
[section Servers (Advanced)]
2017-08-04 19:55:28 -07:00
These servers offer both HTTP and WebSocket services on the same port,
and illustrate the implementation of advanced features.
2017-06-23 01:44:25 -07:00
2017-08-04 19:55:28 -07:00
[table
2019-01-21 10:18:45 -08:00
[[Description] [Features] [Sources]]
2017-08-04 19:55:28 -07:00
[
[Advanced]
[[itemized_list
[Timeouts]
2019-02-19 16:30:05 -08:00
[Multi-threaded]
2017-08-04 19:55:28 -07:00
[HTTP pipelining]
2017-12-15 09:00:44 -08:00
[Dual protocols: HTTP and WebSocket]
[Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)]
]]
2017-08-04 19:55:28 -07:00
[[example_src example/advanced/server/advanced_server.cpp advanced_server.cpp]]
][
[Advanced, flex (plain + SSL)]
[[itemized_list
[Timeouts]
2019-02-19 16:30:05 -08:00
[Multi-threaded]
2017-08-04 19:55:28 -07:00
[HTTP pipelining]
[Dual protocols: HTTP and WebSocket]
[Flexible ports: plain and SSL on the same port]
[Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)]
]]
2017-08-04 19:55:28 -07:00
[[example_src example/advanced/server-flex/advanced_server_flex.cpp advanced_server_flex.cpp]]
2019-01-21 10:18:45 -08:00
][
[Chat Server, multi-threaded]
[[itemized_list
2019-02-19 16:30:05 -08:00
[Multi-threaded]
2019-01-21 10:18:45 -08:00
[Broadcasting Messages]
[Multi-user Chat Server]
[JavaScript Browser Client]
2019-01-21 10:18:45 -08:00
[Dual protocols: HTTP and WebSocket]
[Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)]
]]
[[source_file example/websocket/server/chat-multi]]
2017-08-04 19:55:28 -07:00
]]
2017-06-23 01:44:25 -07:00
2017-08-08 06:20:24 -07:00
[endsect]
2019-02-23 21:00:58 -08:00
[/-----------------------------------------------------------------------------]
2017-08-08 06:20:24 -07:00
2019-02-23 21:00:58 -08:00
[section:chat_server Chat Server __video__ __new__]
2017-08-08 06:20:24 -07:00
2019-02-23 21:00:58 -08:00
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.
2019-02-23 21:00:58 -08:00
[table Chat WebSocket Server and JavaScript Client
[[Component] [Features] [Sources]]
[
[Server]
[[itemized_list
[C++]
[Timeouts]
[Multi-threaded]
[Broadcast to multiple peers]
[Dual protocols: HTTP and WebSocket]
[Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)]
]]
[[source_file example/websocket/server/chat-multi]]
][
[Client]
[[itemized_list
[JavaScript / HTML5]
[Runs in the browser]
[Delivered by the server]
[Only 60 lines total including UI]
[Completely portable graphics]
]]
[[source_file example/websocket/server/chat-multi/chat_client.html]]
]]
2019-02-23 21:00:58 -08:00
[/ "Get rich quick! Using Boost.Beast WebSockets and Networking TS"]
'''
<mediaobject>
<videoobject>
<videodata fileref="https://www.youtube.com/embed/7FQwAjELMek"
align="center" contentwidth="560" contentdepth="315"/>
</videoobject>
</mediaobject>
2019-02-23 21:00:58 -08:00
'''
[endsect]
2019-02-23 21:00:58 -08:00
[/-----------------------------------------------------------------------------]
2017-06-16 19:27:00 -07:00
2016-09-25 11:19:51 -04:00
[endsect]