_examples.qbk 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. [/
  2. Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. Official repository: https://github.com/boostorg/beast
  6. ]
  7. [section Examples]
  8. [block'''<?dbhtml stop-chunking?>''']
  9. Source code and build scripts for these programs are located
  10. in the [path_link example example] directory.
  11. [/-----------------------------------------------------------------------------]
  12. [section Clients]
  13. These HTTP clients submit a GET request to a server specified on the command
  14. line, and prints the resulting response. The crawl client asynchronously
  15. fetches the document root of the 10,000 top ranked domains, this may be
  16. used to evaluate robustness. All asynchronous clients support timeouts.
  17. [table
  18. [[Description] [Source File] [Source File (using SSL)]]
  19. [
  20. [HTTP, synchronous]
  21. [[path_link example/http/client/sync/http_client_sync.cpp http_client_sync.cpp]]
  22. [[path_link example/http/client/sync-ssl/http_client_sync_ssl.cpp http_client_sync_ssl.cpp]]
  23. ][
  24. [HTTP, asynchronous]
  25. [[path_link example/http/client/async/http_client_async.cpp http_client_async.cpp]]
  26. [[path_link example/http/client/async-ssl/http_client_async_ssl.cpp http_client_async_ssl.cpp]]
  27. ][
  28. [HTTP, asynchronous using __system_executor__]
  29. []
  30. [[path_link example/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp http_client_async_ssl_system_executor.cpp]]
  31. ][
  32. [HTTP, coroutine]
  33. [[path_link example/http/client/coro/http_client_coro.cpp http_client_coro.cpp]]
  34. [[path_link example/http/client/coro-ssl/http_client_coro_ssl.cpp http_client_coro_ssl.cpp]]
  35. ][
  36. [HTTP crawl (asynchronous)]
  37. [[path_link example/http/client/crawl/http_crawl.cpp http_crawl.cpp]]
  38. []
  39. ]]
  40. These WebSocket clients connect to a
  41. server and send a message, then receive a message and print the response
  42. before disconnecting. All asynchronous clients support timeouts.
  43. [table
  44. [[Description] [Source File] [Source File (using SSL)]]
  45. [
  46. [WebSocket, synchronous]
  47. [[path_link example/websocket/client/sync/websocket_client_sync.cpp websocket_client_sync.cpp]]
  48. [[path_link example/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp websocket_client_sync_ssl.cpp]]
  49. ][
  50. [WebSocket, asynchronous]
  51. [[path_link example/websocket/client/async/websocket_client_async.cpp websocket_client_async.cpp]]
  52. [[path_link example/websocket/client/async-ssl/websocket_client_async_ssl.cpp websocket_client_async_ssl.cpp]]
  53. ][
  54. [WebSocket, asynchronous using __system_executor__]
  55. []
  56. [[path_link example/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp websocket_client_async_ssl_system_executor.cpp]]
  57. ][
  58. [WebSocket, coroutine]
  59. [[path_link example/websocket/client/coro/websocket_client_coro.cpp websocket_client_coro.cpp]]
  60. [[path_link example/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp websocket_client_coro_ssl.cpp]]
  61. ]]
  62. [endsect]
  63. [/-----------------------------------------------------------------------------]
  64. [section Servers]
  65. These HTTP servers deliver files from a root directory specified on the
  66. command line. All asynchronous servers support timeouts.
  67. [table
  68. [[Description] [Source File] [Source File (using SSL)]]
  69. [
  70. [HTTP, synchronous]
  71. [[path_link example/http/server/sync/http_server_sync.cpp http_server_sync.cpp]]
  72. [[path_link example/http/server/sync-ssl/http_server_sync_ssl.cpp http_server_sync_ssl.cpp]]
  73. ][
  74. [HTTP, asynchronous]
  75. [[path_link example/http/server/async/http_server_async.cpp http_server_async.cpp]]
  76. [[path_link example/http/server/async-ssl/http_server_async_ssl.cpp http_server_async_ssl.cpp]]
  77. ][
  78. [HTTP, coroutine]
  79. [[path_link example/http/server/coro/http_server_coro.cpp http_server_coro.cpp]]
  80. [[path_link example/http/server/coro-ssl/http_server_coro_ssl.cpp http_server_coro_ssl.cpp]]
  81. ][
  82. [HTTP, stackless coroutine]
  83. [[path_link example/http/server/stackless/http_server_stackless.cpp http_server_stackless.cpp]]
  84. [[path_link example/http/server/stackless-ssl/http_server_stackless_ssl.cpp http_server_stackless_ssl.cpp]]
  85. ][
  86. [HTTP, fast (optimized for speed)]
  87. [[path_link example/http/server/fast/http_server_fast.cpp http_server_fast.cpp]]
  88. []
  89. ][
  90. [HTTP, small (optimized for space)]
  91. [[path_link example/http/server/small/http_server_small.cpp http_server_small.cpp]]
  92. []
  93. ][
  94. [HTTP, flex (plain + SSL)]
  95. []
  96. [[path_link example/http/server/flex/http_server_flex.cpp http_server_flex.cpp]]
  97. ]]
  98. These WebSocket servers echo back any message received, keeping the
  99. session open until the client disconnects. All asynchronous servers
  100. support timeouts.
  101. [table
  102. [[Description] [Source File] [Source File (using SSL)]]
  103. [
  104. [WebSocket, synchronous]
  105. [[path_link example/websocket/server/sync/websocket_server_sync.cpp websocket_server_sync.cpp]]
  106. [[path_link example/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp websocket_server_sync_ssl.cpp]]
  107. ][
  108. [WebSocket, asynchronous]
  109. [[path_link example/websocket/server/async/websocket_server_async.cpp websocket_server_async.cpp]]
  110. [[path_link example/websocket/server/async-ssl/websocket_server_async_ssl.cpp websocket_server_async_ssl.cpp]]
  111. ][
  112. [WebSocket, coroutine]
  113. [[path_link example/websocket/server/coro/websocket_server_coro.cpp websocket_server_coro.cpp]]
  114. [[path_link example/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp websocket_server_coro_ssl.cpp]]
  115. ][
  116. [WebSocket, stackless coroutine]
  117. [[path_link example/websocket/server/stackless/websocket_server_stackless.cpp websocket_server_stackless.cpp]]
  118. [[path_link example/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp websocket_server_stackless_ssl.cpp]]
  119. ][
  120. [WebSocket, fast (suited for benchmarks)]
  121. [[path_link example/websocket/server/fast/websocket_server_fast.cpp websocket_server_fast.cpp]]
  122. []
  123. ]]
  124. [endsect]
  125. [/-----------------------------------------------------------------------------]
  126. [section Servers (Advanced)]
  127. These servers offer both HTTP and WebSocket services on the same port,
  128. and illustrate the implementation of advanced features.
  129. [table
  130. [[Description] [Features] [Sources]]
  131. [
  132. [Advanced]
  133. [[itemized_list
  134. [Timeouts]
  135. [Multi-threaded]
  136. [HTTP pipelining]
  137. [Parser-oriented HTTP reading]
  138. [Dual protocols: HTTP and WebSocket]
  139. [Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)]
  140. ]]
  141. [[path_link example/advanced/server/advanced_server.cpp advanced_server.cpp]]
  142. ][
  143. [Advanced, flex (plain + SSL)]
  144. [[itemized_list
  145. [Timeouts]
  146. [Multi-threaded]
  147. [HTTP pipelining]
  148. [Parser-oriented HTTP reading]
  149. [Dual protocols: HTTP and WebSocket]
  150. [Flexible ports: plain and SSL on the same port]
  151. [Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)]
  152. ]]
  153. [[path_link example/advanced/server-flex/advanced_server_flex.cpp advanced_server_flex.cpp]]
  154. ][
  155. [Chat Server, multi-threaded]
  156. [[itemized_list
  157. [Multi-threaded]
  158. [Broadcasting Messages]
  159. [Multi-user Chat Server]
  160. [JavaScript Browser Client]
  161. [Parser-oriented HTTP reading]
  162. [Dual protocols: HTTP and WebSocket]
  163. [Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)]
  164. ]]
  165. [[path_link example/websocket/server/chat-multi chat-multi]]
  166. ]]
  167. [endsect]
  168. [/-----------------------------------------------------------------------------]
  169. [section:chat_server Chat Server __video__]
  170. This example demonstrates a websocket chat server, allowing multiple
  171. users to connect and participate in live, group messaging. It comes
  172. with a tiny front end implemented in JavaScript and HTML5 which runs
  173. in any browser. The example is accompanied by a one hour presentation
  174. which provides a discussion of networking concepts, followed by in-depth
  175. explanation of how the client and server are constructed. This talk
  176. was delivered at [@https://cppcon.org CppCon 2018]. The source code
  177. in the Beast example contains improvements to the original program.
  178. [table Chat WebSocket Server and JavaScript Client
  179. [[Component] [Features] [Sources]]
  180. [
  181. [Server]
  182. [[itemized_list
  183. [C++]
  184. [Timeouts]
  185. [Multi-threaded]
  186. [Broadcast to multiple peers]
  187. [Dual protocols: HTTP and WebSocket]
  188. [Clean exit via SIGINT (CTRL+C) or SIGTERM (kill)]
  189. ]]
  190. [[path_link example/websocket/server/chat-multi chat-multi]]
  191. ][
  192. [Client]
  193. [[itemized_list
  194. [JavaScript / HTML5]
  195. [Runs in the browser]
  196. [Delivered by the server]
  197. [Only 60 lines total including UI]
  198. [Completely portable graphics]
  199. ]]
  200. [[path_link example/websocket/server/chat-multi/chat_client.html chat_client.html]]
  201. ]]
  202. [/ "Get rich quick! Using Boost.Beast WebSockets and Networking TS"]
  203. '''
  204. <mediaobject>
  205. <videoobject>
  206. <videodata fileref="https://www.youtube.com/embed/7FQwAjELMek"
  207. align="center" contentwidth="560" contentdepth="315"/>
  208. </videoobject>
  209. </mediaobject>
  210. '''
  211. [endsect]
  212. [/-----------------------------------------------------------------------------]
  213. [endsect]