nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 2534 lines 113 kB view raw
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2From: Amini Allight <amini.allight@protonmail.com> 3Date: Wed, 12 Feb 2025 03:53:35 +0000 4Subject: [PATCH 1/7] fixed incompatibility with Boost 1.87 due to use of 5 previously-deprecated now-removed functionality 6 7(cherry picked from commit 146925c2404655dbb61b9a18e57692bfc18eb6c6) 8 9 Conflicts: 10 examples/broadcast_server/broadcast_server.cpp 11 websocketpp/transport/asio/endpoint.hpp 12 websocketpp/transport/asio/security/none.hpp 13 websocketpp/transport/asio/security/tls.hpp 14--- 15 SConstruct | 4 +- 16 docs/faq.dox | 12 +- 17 .../broadcast_server/broadcast_server.cpp | 2 +- 18 examples/debug_client/debug_client.cpp | 2 +- 19 examples/debug_server/debug_server.cpp | 2 +- 20 examples/echo_client/echo_client.cpp | 2 +- 21 examples/echo_server/echo_server.cpp | 2 +- 22 .../echo_server_both/echo_server_both.cpp | 8 +- 23 examples/echo_server_tls/echo_server_tls.cpp | 2 +- 24 .../CMakeLists.txt | 2 +- 25 .../SConscript | 4 +- 26 .../external_io_context.cpp} | 14 +- 27 .../tcp_echo_server.hpp | 12 +- 28 examples/print_client/print_client.cpp | 2 +- 29 .../print_client_tls/print_client_tls.cpp | 2 +- 30 examples/scratch_server/scratch_server.cpp | 2 +- 31 examples/sip_client/sip_client.cpp | 2 +- 32 .../telemetry_client/telemetry_client.cpp | 4 +- 33 .../telemetry_server/telemetry_server.cpp | 2 +- 34 examples/testee_client/testee_client.cpp | 2 +- 35 examples/testee_server/testee_server.cpp | 2 +- 36 test/endpoint/endpoint.cpp | 6 +- 37 test/transport/asio/timers.cpp | 8 +- 38 test/transport/integration.cpp | 27 ++- 39 tutorials/utility_server/step1.cpp | 2 +- 40 tutorials/utility_server/step2.cpp | 2 +- 41 tutorials/utility_server/utility_server.md | 8 +- 42 websocketpp/roles/server_endpoint.hpp | 4 +- 43 websocketpp/transport/asio/base.hpp | 2 +- 44 websocketpp/transport/asio/connection.hpp | 44 ++--- 45 websocketpp/transport/asio/endpoint.hpp | 182 +++++++++--------- 46 websocketpp/transport/asio/security/none.hpp | 16 +- 47 websocketpp/transport/asio/security/tls.hpp | 20 +- 48 websocketpp/transport/debug/endpoint.hpp | 2 +- 49 websocketpp/transport/iostream/endpoint.hpp | 2 +- 50 websocketpp/transport/stub/endpoint.hpp | 2 +- 51 36 files changed, 205 insertions(+), 208 deletions(-) 52 rename examples/{external_io_service => external_io_context}/CMakeLists.txt (87%) 53 rename examples/{external_io_service => external_io_context}/SConscript (72%) 54 rename examples/{external_io_service/external_io_service.cpp => external_io_context/external_io_context.cpp} (92%) 55 rename examples/{external_io_service => external_io_context}/tcp_echo_server.hpp (92%) 56 57diff --git a/SConstruct b/SConstruct 58index ae3df10..08a75a3 100644 59--- a/SConstruct 60+++ b/SConstruct 61@@ -271,8 +271,8 @@ subprotocol_server = SConscript('#/examples/subprotocol_server/SConscript',varia 62 # telemetry_server 63 telemetry_server = SConscript('#/examples/telemetry_server/SConscript',variant_dir = builddir + 'telemetry_server',duplicate = 0) 64 65-# external_io_service 66-external_io_service = SConscript('#/examples/external_io_service/SConscript',variant_dir = builddir + 'external_io_service',duplicate = 0) 67+# external_io_context 68+external_io_context = SConscript('#/examples/external_io_context/SConscript',variant_dir = builddir + 'external_io_context',duplicate = 0) 69 70 if not env['PLATFORM'].startswith('win'): 71 # iostream_server 72diff --git a/docs/faq.dox b/docs/faq.dox 73index 9f417ec..c89e85b 100644 74--- a/docs/faq.dox 75+++ b/docs/faq.dox 76@@ -29,19 +29,19 @@ Note: some browsers will allow the connection to continue if they requested a su 77 78 ### How do I cleanly exit an Asio transport based program 79 80-The Asio transport based clients and servers use the Asio library's underlying `io_service` to handle asyncronous networking operations. The standard behavior of the io_service is to run until there are no async operations left and then return. WebSocket++, when using the Asio transport, behaves like a standard Asio application. If you want your WebSocket++/Asio based program to stop network operations and cleanly close all sockets you will want to do the following: 81+The Asio transport based clients and servers use the Asio library's underlying `io_context` to handle asyncronous networking operations. The standard behavior of the io_context is to run until there are no async operations left and then return. WebSocket++, when using the Asio transport, behaves like a standard Asio application. If you want your WebSocket++/Asio based program to stop network operations and cleanly close all sockets you will want to do the following: 82 83 - For servers, call `websocketpp::transport::asio::endpoint::stop_listening` to initiate the closing of the server listening socket. 84 - For clients, if you have engaged perpetual mode with `websocketpp::transport::asio::endpoint::start_perpetual`, disable it with `websocketpp::transport::asio::endpoint::stop_perpetual`. 85 - For both, run `websocketpp::endpoint::close` or `websocketpp::connection::close` on all currently outstanding connections. This will initiate the WebSocket closing handshake for these connections 86-- Wait. Asio is asyncronous. When the calls to the above methods (stop_listening, close, etc) complete the server *will still be listening*, the connections *will still be active* until the io_service gets around to asyncronously processing the socket and WebSocket protocol closing handshakes. The `io_service::run` method will exit cleanly and automatically when all operations are complete. 87+- Wait. Asio is asyncronous. When the calls to the above methods (stop_listening, close, etc) complete the server *will still be listening*, the connections *will still be active* until the io_context gets around to asyncronously processing the socket and WebSocket protocol closing handshakes. The `io_context::run` method will exit cleanly and automatically when all operations are complete. 88 89-__WARNING__: Asio's `io_service` has a method called `stop`. WebSocket++ wraps this method as `websocketpp::transport::asio::endpoint::stop`. While this operation has a benign sounding name, it is a powerful and destructive operation that should only be used in special cases. If you are using `io_service::stop` or `endpoint::stop` without a very good reason your program is likely broken and may exhibit erratic behavior. Specifically, `io_service::stop` stops the processing of events entirely. This does not give current operations (such as socket closing handshakes) the opportunity to finish. It will leave your sockets in a dangling state that may invoke operating system level timeouts or other errors. 90+__WARNING__: Asio's `io_context` has a method called `stop`. WebSocket++ wraps this method as `websocketpp::transport::asio::endpoint::stop`. While this operation has a benign sounding name, it is a powerful and destructive operation that should only be used in special cases. If you are using `io_context::stop` or `endpoint::stop` without a very good reason your program is likely broken and may exhibit erratic behavior. Specifically, `io_context::stop` stops the processing of events entirely. This does not give current operations (such as socket closing handshakes) the opportunity to finish. It will leave your sockets in a dangling state that may invoke operating system level timeouts or other errors. 91 92 __Special cases__: 93-- If your client uses the `start_perpetual` method it will prevent the io_service from exiting even if it has nothing to do. This is useful if you want a client endpoint to idle in the background to allow new connections to be formed on demand rather than generating a new endpoint for each. 94-- If you are using an external io_service and/or are placing non-WebSocket++ operations on the `io_service` those operations may keep the `io_service` open even after all WebSocket++ operations have completed. 95-- If you are using `poll`/`poll_one`/`run_one` or otherwise manually driving the `io_service` event loop you may need to adjust usage to make sure you are correctly recognizing the "done with work" and "not done but idling / `io_service::work`" cases. 96+- If your client uses the `start_perpetual` method it will prevent the io_context from exiting even if it has nothing to do. This is useful if you want a client endpoint to idle in the background to allow new connections to be formed on demand rather than generating a new endpoint for each. 97+- If you are using an external io_context and/or are placing non-WebSocket++ operations on the `io_context` those operations may keep the `io_context` open even after all WebSocket++ operations have completed. 98+- If you are using `poll`/`poll_one`/`run_one` or otherwise manually driving the `io_context` event loop you may need to adjust usage to make sure you are correctly recognizing the "done with work" and "not done but idling / `io_context::work`" cases. 99 100 ### Is there a way to check the validity of a `connection_hdl`? 101 102diff --git a/examples/broadcast_server/broadcast_server.cpp b/examples/broadcast_server/broadcast_server.cpp 103index b02e7cd..106eba7 100644 104--- a/examples/broadcast_server/broadcast_server.cpp 105+++ b/examples/broadcast_server/broadcast_server.cpp 106@@ -63,7 +63,7 @@ public: 107 // Start the server accept loop 108 m_server.start_accept(); 109 110- // Start the ASIO io_service run loop 111+ // Start the ASIO io_context run loop 112 try { 113 m_server.run(); 114 } catch (const std::exception & e) { 115diff --git a/examples/debug_client/debug_client.cpp b/examples/debug_client/debug_client.cpp 116index d3e9153..d3e21ab 100644 117--- a/examples/debug_client/debug_client.cpp 118+++ b/examples/debug_client/debug_client.cpp 119@@ -83,7 +83,7 @@ public: 120 121 m_endpoint.connect(con); 122 123- // Start the ASIO io_service run loop 124+ // Start the ASIO io_context run loop 125 m_start = std::chrono::high_resolution_clock::now(); 126 m_endpoint.run(); 127 } 128diff --git a/examples/debug_server/debug_server.cpp b/examples/debug_server/debug_server.cpp 129index 8d1ff0e..3748800 100644 130--- a/examples/debug_server/debug_server.cpp 131+++ b/examples/debug_server/debug_server.cpp 132@@ -162,7 +162,7 @@ int main() { 133 // Start the server accept loop 134 echo_server.start_accept(); 135 136- // Start the ASIO io_service run loop 137+ // Start the ASIO io_context run loop 138 echo_server.run(); 139 } catch (websocketpp::exception const & e) { 140 std::cout << e.what() << std::endl; 141diff --git a/examples/echo_client/echo_client.cpp b/examples/echo_client/echo_client.cpp 142index 59af661..88171d9 100644 143--- a/examples/echo_client/echo_client.cpp 144+++ b/examples/echo_client/echo_client.cpp 145@@ -87,7 +87,7 @@ int main(int argc, char* argv[]) { 146 // exchanged until the event loop starts running in the next line. 147 c.connect(con); 148 149- // Start the ASIO io_service run loop 150+ // Start the ASIO io_context run loop 151 // this will cause a single connection to be made to the server. c.run() 152 // will exit when this connection is closed. 153 c.run(); 154diff --git a/examples/echo_server/echo_server.cpp b/examples/echo_server/echo_server.cpp 155index d234009..639c79f 100644 156--- a/examples/echo_server/echo_server.cpp 157+++ b/examples/echo_server/echo_server.cpp 158@@ -55,7 +55,7 @@ int main() { 159 // Start the server accept loop 160 echo_server.start_accept(); 161 162- // Start the ASIO io_service run loop 163+ // Start the ASIO io_context run loop 164 echo_server.run(); 165 } catch (websocketpp::exception const & e) { 166 std::cout << e.what() << std::endl; 167diff --git a/examples/echo_server_both/echo_server_both.cpp b/examples/echo_server_both/echo_server_both.cpp 168index 2c2c4ea..869c006 100644 169--- a/examples/echo_server_both/echo_server_both.cpp 170+++ b/examples/echo_server_both/echo_server_both.cpp 171@@ -58,13 +58,13 @@ context_ptr on_tls_init(websocketpp::connection_hdl hdl) { 172 } 173 174 int main() { 175- // set up an external io_service to run both endpoints on. This is not 176+ // set up an external io_context to run both endpoints on. This is not 177 // strictly necessary, but simplifies thread management a bit. 178- boost::asio::io_service ios; 179+ boost::asio::io_context ios; 180 181 // set up plain endpoint 182 server_plain endpoint_plain; 183- // initialize asio with our external io_service rather than an internal one 184+ // initialize asio with our external io_context rather than an internal one 185 endpoint_plain.init_asio(&ios); 186 endpoint_plain.set_message_handler( 187 bind(&on_message<server_plain>,&endpoint_plain,::_1,::_2)); 188@@ -82,6 +82,6 @@ int main() { 189 endpoint_tls.listen(443); 190 endpoint_tls.start_accept(); 191 192- // Start the ASIO io_service run loop running both endpoints 193+ // Start the ASIO io_context run loop running both endpoints 194 ios.run(); 195 } 196diff --git a/examples/echo_server_tls/echo_server_tls.cpp b/examples/echo_server_tls/echo_server_tls.cpp 197index 3d704f5..2f75a7d 100644 198--- a/examples/echo_server_tls/echo_server_tls.cpp 199+++ b/examples/echo_server_tls/echo_server_tls.cpp 200@@ -148,7 +148,7 @@ int main() { 201 // Start the server accept loop 202 echo_server.start_accept(); 203 204- // Start the ASIO io_service run loop 205+ // Start the ASIO io_context run loop 206 echo_server.run(); 207 208 } 209diff --git a/examples/external_io_service/CMakeLists.txt b/examples/external_io_context/CMakeLists.txt 210similarity index 87% 211rename from examples/external_io_service/CMakeLists.txt 212rename to examples/external_io_context/CMakeLists.txt 213index 5223da1..a0e89ec 100644 214--- a/examples/external_io_service/CMakeLists.txt 215+++ b/examples/external_io_context/CMakeLists.txt 216@@ -2,7 +2,7 @@ 217 file (GLOB SOURCE_FILES *.cpp) 218 file (GLOB HEADER_FILES *.hpp) 219 220-init_target (external_io_service) 221+init_target (external_io_context) 222 223 build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES}) 224 225diff --git a/examples/external_io_service/SConscript b/examples/external_io_context/SConscript 226similarity index 72% 227rename from examples/external_io_service/SConscript 228rename to examples/external_io_context/SConscript 229index beb7c1c..57305aa 100644 230--- a/examples/external_io_service/SConscript 231+++ b/examples/external_io_context/SConscript 232@@ -15,9 +15,9 @@ prgs = [] 233 # if a C++11 environment is available build using that, otherwise use boost 234 if env_cpp11.has_key('WSPP_CPP11_ENABLED'): 235 ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs] 236- prgs += env_cpp11.Program('external_io_service', ["external_io_service.cpp"], LIBS = ALL_LIBS) 237+ prgs += env_cpp11.Program('external_io_context', ["external_io_context.cpp"], LIBS = ALL_LIBS) 238 else: 239 ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs] 240- prgs += env.Program('external_io_service', ["external_io_service.cpp"], LIBS = ALL_LIBS) 241+ prgs += env.Program('external_io_context', ["external_io_context.cpp"], LIBS = ALL_LIBS) 242 243 Return('prgs') 244diff --git a/examples/external_io_service/external_io_service.cpp b/examples/external_io_context/external_io_context.cpp 245similarity index 92% 246rename from examples/external_io_service/external_io_service.cpp 247rename to examples/external_io_context/external_io_context.cpp 248index 7372d59..c5ba0a4 100644 249--- a/examples/external_io_service/external_io_service.cpp 250+++ b/examples/external_io_context/external_io_context.cpp 251@@ -59,10 +59,10 @@ void on_message(ws_echo_server* s, websocketpp::connection_hdl hdl, ws_echo_serv 252 } 253 254 int main() { 255- asio::io_service service; 256+ asio::io_context context; 257 258 // Add a TCP echo server on port 9003 259- tcp_echo_server custom_http_server(service, 9003); 260+ tcp_echo_server custom_http_server(context, 9003); 261 262 // Add a WebSocket echo server on port 9002 263 ws_echo_server ws_server; 264@@ -70,8 +70,8 @@ int main() { 265 ws_server.clear_access_channels(websocketpp::log::alevel::frame_payload); 266 267 // The only difference in this code between an internal and external 268- // io_service is the different constructor to init_asio 269- ws_server.init_asio(&service); 270+ // io_context is the different constructor to init_asio 271+ ws_server.init_asio(&context); 272 273 // Register our message handler 274 ws_server.set_message_handler(bind(&on_message,&ws_server,::_1,::_2)); 275@@ -80,6 +80,6 @@ int main() { 276 277 // TODO: add a timer? 278 279- // Start the Asio io_service run loop for all 280- service.run(); 281-} 282\ No newline at end of file 283+ // Start the Asio io_context run loop for all 284+ context.run(); 285+} 286diff --git a/examples/external_io_service/tcp_echo_server.hpp b/examples/external_io_context/tcp_echo_server.hpp 287similarity index 92% 288rename from examples/external_io_service/tcp_echo_server.hpp 289rename to examples/external_io_context/tcp_echo_server.hpp 290index ef4ce18..2e14703 100644 291--- a/examples/external_io_service/tcp_echo_server.hpp 292+++ b/examples/external_io_context/tcp_echo_server.hpp 293@@ -44,7 +44,7 @@ namespace asio = websocketpp::lib::asio; 294 struct tcp_echo_session : websocketpp::lib::enable_shared_from_this<tcp_echo_session> { 295 typedef websocketpp::lib::shared_ptr<tcp_echo_session> ptr; 296 297- tcp_echo_session(asio::io_service & service) : m_socket(service) {} 298+ tcp_echo_session(asio::io_context & context) : m_socket(context) {} 299 300 void start() { 301 m_socket.async_read_some(asio::buffer(m_buffer, sizeof(m_buffer)), 302@@ -72,15 +72,15 @@ struct tcp_echo_session : websocketpp::lib::enable_shared_from_this<tcp_echo_ses 303 }; 304 305 struct tcp_echo_server { 306- tcp_echo_server(asio::io_service & service, short port) 307- : m_service(service) 308- , m_acceptor(service, asio::ip::tcp::endpoint(asio::ip::tcp::v6(), port)) 309+ tcp_echo_server(asio::io_context & context, short port) 310+ : m_context(context) 311+ , m_acceptor(context, asio::ip::tcp::endpoint(asio::ip::tcp::v6(), port)) 312 { 313 this->start_accept(); 314 } 315 316 void start_accept() { 317- tcp_echo_session::ptr new_session(new tcp_echo_session(m_service)); 318+ tcp_echo_session::ptr new_session(new tcp_echo_session(m_context)); 319 m_acceptor.async_accept(new_session->m_socket, 320 bind(&tcp_echo_server::handle_accept, this, new_session, _1)); 321 } 322@@ -92,6 +92,6 @@ struct tcp_echo_server { 323 start_accept(); 324 } 325 326- asio::io_service & m_service; 327+ asio::io_context & m_context; 328 asio::ip::tcp::acceptor m_acceptor; 329 }; 330diff --git a/examples/print_client/print_client.cpp b/examples/print_client/print_client.cpp 331index 7ba6e5f..20a2bd3 100644 332--- a/examples/print_client/print_client.cpp 333+++ b/examples/print_client/print_client.cpp 334@@ -68,7 +68,7 @@ int main(int argc, char* argv[]) { 335 // exchanged until the event loop starts running in the next line. 336 c.connect(con); 337 338- // Start the ASIO io_service run loop 339+ // Start the ASIO io_context run loop 340 // this will cause a single connection to be made to the server. c.run() 341 // will exit when this connection is closed. 342 c.run(); 343diff --git a/examples/print_client_tls/print_client_tls.cpp b/examples/print_client_tls/print_client_tls.cpp 344index 469d9c6..43164ea 100644 345--- a/examples/print_client_tls/print_client_tls.cpp 346+++ b/examples/print_client_tls/print_client_tls.cpp 347@@ -239,7 +239,7 @@ int main(int argc, char* argv[]) { 348 349 c.get_alog().write(websocketpp::log::alevel::app, "Connecting to " + uri); 350 351- // Start the ASIO io_service run loop 352+ // Start the ASIO io_context run loop 353 // this will cause a single connection to be made to the server. c.run() 354 // will exit when this connection is closed. 355 c.run(); 356diff --git a/examples/scratch_server/scratch_server.cpp b/examples/scratch_server/scratch_server.cpp 357index 901ae8e..dab20b9 100644 358--- a/examples/scratch_server/scratch_server.cpp 359+++ b/examples/scratch_server/scratch_server.cpp 360@@ -94,7 +94,7 @@ int main(int argc, char * argv[]) { 361 // Start the server accept loop 362 echo_server.start_accept(); 363 364- // Start the ASIO io_service run loop 365+ // Start the ASIO io_context run loop 366 echo_server.run(); 367 } catch (websocketpp::exception const & e) { 368 std::cout << e.what() << std::endl; 369diff --git a/examples/sip_client/sip_client.cpp b/examples/sip_client/sip_client.cpp 370index 66fa857..c9f33e7 100644 371--- a/examples/sip_client/sip_client.cpp 372+++ b/examples/sip_client/sip_client.cpp 373@@ -69,7 +69,7 @@ int main(int argc, char* argv[]) { 374 375 sip_client.connect(con); 376 377- // Start the ASIO io_service run loop 378+ // Start the ASIO io_context run loop 379 sip_client.run(); 380 381 while(!received) { 382diff --git a/examples/telemetry_client/telemetry_client.cpp b/examples/telemetry_client/telemetry_client.cpp 383index f0f7fae..12390b8 100644 384--- a/examples/telemetry_client/telemetry_client.cpp 385+++ b/examples/telemetry_client/telemetry_client.cpp 386@@ -62,10 +62,10 @@ public: 387 m_hdl = con->get_handle(); 388 389 // Queue the connection. No DNS queries or network connections will be 390- // made until the io_service event loop is run. 391+ // made until the io_context event loop is run. 392 m_client.connect(con); 393 394- // Create a thread to run the ASIO io_service event loop 395+ // Create a thread to run the ASIO io_context event loop 396 websocketpp::lib::thread asio_thread(&client::run, &m_client); 397 398 // Create a thread to run the telemetry loop 399diff --git a/examples/telemetry_server/telemetry_server.cpp b/examples/telemetry_server/telemetry_server.cpp 400index 3f8e604..2286c50 100644 401--- a/examples/telemetry_server/telemetry_server.cpp 402+++ b/examples/telemetry_server/telemetry_server.cpp 403@@ -66,7 +66,7 @@ public: 404 // Set the initial timer to start telemetry 405 set_timer(); 406 407- // Start the ASIO io_service run loop 408+ // Start the ASIO io_context run loop 409 try { 410 m_endpoint.run(); 411 } catch (websocketpp::exception const & e) { 412diff --git a/examples/testee_client/testee_client.cpp b/examples/testee_client/testee_client.cpp 413index b66e633..12583e5 100644 414--- a/examples/testee_client/testee_client.cpp 415+++ b/examples/testee_client/testee_client.cpp 416@@ -117,7 +117,7 @@ int main(int argc, char* argv[]) { 417 client::connection_ptr con = c.get_connection(uri+"/getCaseCount", ec); 418 c.connect(con); 419 420- // Start the ASIO io_service run loop 421+ // Start the ASIO io_context run loop 422 c.run(); 423 424 std::cout << "case count: " << case_count << std::endl; 425diff --git a/examples/testee_server/testee_server.cpp b/examples/testee_server/testee_server.cpp 426index 9ac9a7d..13e574e 100644 427--- a/examples/testee_server/testee_server.cpp 428+++ b/examples/testee_server/testee_server.cpp 429@@ -124,7 +124,7 @@ int main(int argc, char * argv[]) { 430 // Start the server accept loop 431 testee_server.start_accept(); 432 433- // Start the ASIO io_service run loop 434+ // Start the ASIO io_context run loop 435 if (num_threads == 1) { 436 testee_server.run(); 437 } else { 438diff --git a/test/endpoint/endpoint.cpp b/test/endpoint/endpoint.cpp 439index b4c429e..fa58e66 100644 440--- a/test/endpoint/endpoint.cpp 441+++ b/test/endpoint/endpoint.cpp 442@@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE( initialize_server_asio ) { 443 444 BOOST_AUTO_TEST_CASE( initialize_server_asio_external ) { 445 websocketpp::server<websocketpp::config::asio> s; 446- boost::asio::io_service ios; 447+ boost::asio::io_context ios; 448 s.init_asio(&ios); 449 } 450 451@@ -141,8 +141,8 @@ BOOST_AUTO_TEST_CASE( listen_after_listen_failure ) { 452 server1.init_asio(); 453 server2.init_asio(); 454 455- boost::asio::ip::tcp::endpoint ep1(boost::asio::ip::address::from_string("127.0.0.1"), 12345); 456- boost::asio::ip::tcp::endpoint ep2(boost::asio::ip::address::from_string("127.0.0.1"), 23456); 457+ boost::asio::ip::tcp::endpoint ep1(boost::asio::ip::make_address("127.0.0.1"), 12345); 458+ boost::asio::ip::tcp::endpoint ep2(boost::asio::ip::make_address("127.0.0.1"), 23456); 459 460 server1.listen(ep1, ec); 461 BOOST_CHECK(!ec); 462diff --git a/test/transport/asio/timers.cpp b/test/transport/asio/timers.cpp 463index aa03d61..391b755 100644 464--- a/test/transport/asio/timers.cpp 465+++ b/test/transport/asio/timers.cpp 466@@ -54,9 +54,9 @@ void run_dummy_server(int port) { 467 using boost::asio::ip::tcp; 468 469 try { 470- boost::asio::io_service io_service; 471- tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v6(), port)); 472- tcp::socket socket(io_service); 473+ boost::asio::io_context io_context; 474+ tcp::acceptor acceptor(io_context, tcp::endpoint(tcp::v6(), port)); 475+ tcp::socket socket(io_context); 476 477 acceptor.accept(socket); 478 for (;;) { 479@@ -79,7 +79,7 @@ void run_dummy_server(int port) { 480 481 // Wait for the specified time period then fail the test 482 void run_test_timer(long value) { 483- boost::asio::io_service ios; 484+ boost::asio::io_context ios; 485 boost::asio::deadline_timer t(ios,boost::posix_time::milliseconds(value)); 486 boost::system::error_code ec; 487 t.wait(ec); 488diff --git a/test/transport/integration.cpp b/test/transport/integration.cpp 489index c083cfd..ab82b1a 100644 490--- a/test/transport/integration.cpp 491+++ b/test/transport/integration.cpp 492@@ -221,9 +221,9 @@ void run_dummy_server(int port) { 493 using boost::asio::ip::tcp; 494 495 try { 496- boost::asio::io_service io_service; 497- tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v6(), port)); 498- tcp::socket socket(io_service); 499+ boost::asio::io_context io_context; 500+ tcp::acceptor acceptor(io_context, tcp::endpoint(tcp::v6(), port)); 501+ tcp::socket socket(io_context); 502 503 acceptor.accept(socket); 504 for (;;) { 505@@ -248,13 +248,12 @@ void run_dummy_client(std::string port) { 506 using boost::asio::ip::tcp; 507 508 try { 509- boost::asio::io_service io_service; 510- tcp::resolver resolver(io_service); 511- tcp::resolver::query query("localhost", port); 512- tcp::resolver::iterator iterator = resolver.resolve(query); 513- tcp::socket socket(io_service); 514+ boost::asio::io_context io_context; 515+ tcp::resolver resolver(io_context); 516+ tcp::resolver::results_type endpoints = resolver.resolve("localhost", port); 517+ tcp::socket socket(io_context); 518 519- boost::asio::connect(socket, iterator); 520+ boost::asio::connect(socket, endpoints); 521 for (;;) { 522 char data[512]; 523 boost::system::error_code ec; 524@@ -358,11 +357,11 @@ class test_deadline_timer 525 { 526 public: 527 test_deadline_timer(int seconds) 528- : m_timer(m_io_service, boost::posix_time::seconds(seconds)) 529+ : m_timer(m_io_context, boost::posix_time::seconds(seconds)) 530 { 531 m_timer.async_wait(bind(&test_deadline_timer::expired, this, ::_1)); 532- std::size_t (boost::asio::io_service::*run)() = &boost::asio::io_service::run; 533- m_timer_thread = websocketpp::lib::thread(websocketpp::lib::bind(run, &m_io_service)); 534+ std::size_t (boost::asio::io_context::*run)() = &boost::asio::io_context::run; 535+ m_timer_thread = websocketpp::lib::thread(websocketpp::lib::bind(run, &m_io_context)); 536 } 537 ~test_deadline_timer() 538 { 539@@ -379,7 +378,7 @@ public: 540 BOOST_FAIL("Test timed out"); 541 } 542 543- boost::asio::io_service m_io_service; 544+ boost::asio::io_context m_io_context; 545 boost::asio::deadline_timer m_timer; 546 websocketpp::lib::thread m_timer_thread; 547 }; 548@@ -541,7 +540,7 @@ BOOST_AUTO_TEST_CASE( client_runs_out_of_work ) { 549 550 c.run(); 551 552- // This test checks that an io_service with no work ends immediately. 553+ // This test checks that an io_context with no work ends immediately. 554 BOOST_CHECK(true); 555 } 556 557diff --git a/tutorials/utility_server/step1.cpp b/tutorials/utility_server/step1.cpp 558index c0e4643..dae4a2a 100644 559--- a/tutorials/utility_server/step1.cpp 560+++ b/tutorials/utility_server/step1.cpp 561@@ -57,7 +57,7 @@ public: 562 // Queues a connection accept operation 563 m_endpoint.start_accept(); 564 565- // Start the Asio io_service run loop 566+ // Start the Asio io_context run loop 567 m_endpoint.run(); 568 } 569 private: 570diff --git a/tutorials/utility_server/step2.cpp b/tutorials/utility_server/step2.cpp 571index a2815bb..c4fe486 100644 572--- a/tutorials/utility_server/step2.cpp 573+++ b/tutorials/utility_server/step2.cpp 574@@ -68,7 +68,7 @@ public: 575 // Queues a connection accept operation 576 m_endpoint.start_accept(); 577 578- // Start the Asio io_service run loop 579+ // Start the Asio io_context run loop 580 m_endpoint.run(); 581 } 582 private: 583diff --git a/tutorials/utility_server/utility_server.md b/tutorials/utility_server/utility_server.md 584index 1c7ee3f..461eed0 100644 585--- a/tutorials/utility_server/utility_server.md 586+++ b/tutorials/utility_server/utility_server.md 587@@ -56,7 +56,7 @@ m_endpoint.set_access_channels(websocketpp::log::alevel::all ^ websocketpp::log: 588 589 Next, we initialize the transport system underlying the endpoint. This method is specific to the Asio transport not WebSocket++ core. It will not be necessary or present in endpoints that use a non-asio config. 590 591-> **Note:** This example uses an internal Asio `io_service` that is managed by the endpoint itself. This is a simple arrangement suitable for programs where WebSocket++ is the only code using Asio. If you have an existing program that already manages an `io_service` object or want to build a new program where WebSocket++ handlers share an io_service with other handlers you can pass the `io_service` you want WebSocket++ to register its handlers on to the `init_asio()` method and it will use it instead of generating and managing its own. [TODO: FAQ link instead?] 592+> **Note:** This example uses an internal Asio `io_context` that is managed by the endpoint itself. This is a simple arrangement suitable for programs where WebSocket++ is the only code using Asio. If you have an existing program that already manages an `io_context` object or want to build a new program where WebSocket++ handlers share an io_context with other handlers you can pass the `io_context` you want WebSocket++ to register its handlers on to the `init_asio()` method and it will use it instead of generating and managing its own. [TODO: FAQ link instead?] 593 594 ~~~{.cpp} 595 m_endpoint.init_asio(); 596@@ -64,7 +64,7 @@ m_endpoint.init_asio(); 597 598 #### `utility_server::run` method 599 600-In addition to the constructor, we also add a run method that sets up the listening socket, begins accepting connections, starts the Asio io_service event loop. 601+In addition to the constructor, we also add a run method that sets up the listening socket, begins accepting connections, starts the Asio io_context event loop. 602 603 ~~~{.cpp} 604 // Listen on port 9002 605@@ -73,7 +73,7 @@ m_endpoint.listen(9002); 606 // Queues a connection accept operation 607 m_endpoint.start_accept(); 608 609-// Start the Asio io_service run loop 610+// Start the Asio io_context run loop 611 m_endpoint.run(); 612 ~~~ 613 614@@ -123,7 +123,7 @@ public: 615 // Queues a connection accept operation 616 m_endpoint.start_accept(); 617 618- // Start the Asio io_service run loop 619+ // Start the Asio io_context run loop 620 m_endpoint.run(); 621 } 622 private: 623diff --git a/websocketpp/roles/server_endpoint.hpp b/websocketpp/roles/server_endpoint.hpp 624index 9cc652f..ed4b703 100644 625--- a/websocketpp/roles/server_endpoint.hpp 626+++ b/websocketpp/roles/server_endpoint.hpp 627@@ -110,8 +110,8 @@ public: 628 /// Starts the server's async connection acceptance loop (exception free) 629 /** 630 * Initiates the server connection acceptance loop. Must be called after 631- * listen. This method will have no effect until the underlying io_service 632- * starts running. It may be called after the io_service is already running. 633+ * listen. This method will have no effect until the underlying io_context 634+ * starts running. It may be called after the io_context is already running. 635 * 636 * Refer to documentation for the transport policy you are using for 637 * instructions on how to stop this acceptance loop. 638diff --git a/websocketpp/transport/asio/base.hpp b/websocketpp/transport/asio/base.hpp 639index b945fe1..8d980ad 100644 640--- a/websocketpp/transport/asio/base.hpp 641+++ b/websocketpp/transport/asio/base.hpp 642@@ -40,7 +40,7 @@ namespace websocketpp { 643 namespace transport { 644 /// Transport policy that uses asio 645 /** 646- * This policy uses a single asio io_service to provide transport 647+ * This policy uses a single asio io_context to provide transport 648 * services to a WebSocket++ endpoint. 649 */ 650 namespace asio { 651diff --git a/websocketpp/transport/asio/connection.hpp b/websocketpp/transport/asio/connection.hpp 652index 57dda74..eaee6bc 100644 653--- a/websocketpp/transport/asio/connection.hpp 654+++ b/websocketpp/transport/asio/connection.hpp 655@@ -85,10 +85,10 @@ public: 656 typedef typename config::response_type response_type; 657 typedef typename response_type::ptr response_ptr; 658 659- /// Type of a pointer to the Asio io_service being used 660- typedef lib::asio::io_service * io_service_ptr; 661- /// Type of a pointer to the Asio io_service::strand being used 662- typedef lib::shared_ptr<lib::asio::io_service::strand> strand_ptr; 663+ /// Type of a pointer to the Asio io_context being used 664+ typedef lib::asio::io_context * io_context_ptr; 665+ /// Type of a pointer to the Asio io_context::strand being used 666+ typedef lib::shared_ptr<lib::asio::io_context::strand> strand_ptr; 667 /// Type of a pointer to the Asio timer class 668 typedef lib::shared_ptr<lib::asio::steady_timer> timer_ptr; 669 670@@ -97,7 +97,7 @@ public: 671 // to the public api. 672 friend class endpoint<config>; 673 674- // generate and manage our own io_service 675+ // generate and manage our own io_context 676 explicit connection(bool is_server, const lib::shared_ptr<alog_type> & alog, const lib::shared_ptr<elog_type> & elog) 677 : m_is_server(is_server) 678 , m_alog(alog) 679@@ -313,7 +313,7 @@ public: 680 timer_ptr set_timer(long duration, timer_handler callback) { 681 timer_ptr new_timer( 682 new lib::asio::steady_timer( 683- *m_io_service, 684+ *m_io_context, 685 lib::asio::milliseconds(duration)) 686 ); 687 688@@ -393,7 +393,7 @@ public: 689 /// Initialize transport for reading 690 /** 691 * init_asio is called once immediately after construction to initialize 692- * Asio components to the io_service 693+ * Asio components to the io_context 694 * 695 * The transport initialization sequence consists of the following steps: 696 * - Pre-init: the underlying socket is initialized to the point where 697@@ -451,21 +451,21 @@ protected: 698 /// Finish constructing the transport 699 /** 700 * init_asio is called once immediately after construction to initialize 701- * Asio components to the io_service. 702+ * Asio components to the io_context. 703 * 704- * @param io_service A pointer to the io_service to register with this 705+ * @param io_context A pointer to the io_context to register with this 706 * connection 707 * 708 * @return Status code for the success or failure of the initialization 709 */ 710- lib::error_code init_asio (io_service_ptr io_service) { 711- m_io_service = io_service; 712+ lib::error_code init_asio (io_context_ptr io_context) { 713+ m_io_context = io_context; 714 715 if (config::enable_multithreading) { 716- m_strand.reset(new lib::asio::io_service::strand(*io_service)); 717+ m_strand.reset(new lib::asio::io_context::strand(*io_context)); 718 } 719 720- lib::error_code ec = socket_con_type::init_asio(io_service, m_strand, 721+ lib::error_code ec = socket_con_type::init_asio(io_context, m_strand, 722 m_is_server); 723 724 return ec; 725@@ -573,7 +573,7 @@ protected: 726 lib::error_code const & ec) 727 { 728 if (ec == transport::error::operation_aborted || 729- (post_timer && lib::asio::is_neg(post_timer->expires_from_now()))) 730+ (post_timer && lib::asio::is_neg(post_timer->expiry() - std::chrono::steady_clock::now()))) 731 { 732 m_alog->write(log::alevel::devel,"post_init cancelled"); 733 return; 734@@ -679,7 +679,7 @@ protected: 735 // Whatever aborted it will be issuing the callback so we are safe to 736 // return 737 if (ec == lib::asio::error::operation_aborted || 738- lib::asio::is_neg(m_proxy_data->timer->expires_from_now())) 739+ lib::asio::is_neg(m_proxy_data->timer->expiry() - std::chrono::steady_clock::now())) 740 { 741 m_elog->write(log::elevel::devel,"write operation aborted"); 742 return; 743@@ -751,7 +751,7 @@ protected: 744 // Whatever aborted it will be issuing the callback so we are safe to 745 // return 746 if (ec == lib::asio::error::operation_aborted || 747- lib::asio::is_neg(m_proxy_data->timer->expires_from_now())) 748+ lib::asio::is_neg(m_proxy_data->timer->expiry() - std::chrono::steady_clock::now())) 749 { 750 m_elog->write(log::elevel::devel,"read operation aborted"); 751 return; 752@@ -1012,18 +1012,18 @@ protected: 753 */ 754 lib::error_code interrupt(interrupt_handler handler) { 755 if (config::enable_multithreading) { 756- m_io_service->post(m_strand->wrap(handler)); 757+ boost::asio::post(m_io_context->get_executor(), m_strand->wrap(handler)); 758 } else { 759- m_io_service->post(handler); 760+ boost::asio::post(m_io_context->get_executor(), handler); 761 } 762 return lib::error_code(); 763 } 764 765 lib::error_code dispatch(dispatch_handler handler) { 766 if (config::enable_multithreading) { 767- m_io_service->post(m_strand->wrap(handler)); 768+ boost::asio::post(m_io_context->get_executor(), m_strand->wrap(handler)); 769 } else { 770- m_io_service->post(handler); 771+ boost::asio::post(m_io_context->get_executor(), handler); 772 } 773 return lib::error_code(); 774 } 775@@ -1095,7 +1095,7 @@ protected: 776 callback, lib::asio::error_code const & ec) 777 { 778 if (ec == lib::asio::error::operation_aborted || 779- lib::asio::is_neg(shutdown_timer->expires_from_now())) 780+ lib::asio::is_neg(shutdown_timer->expiry() - std::chrono::steady_clock::now())) 781 { 782 m_alog->write(log::alevel::devel,"async_shutdown cancelled"); 783 return; 784@@ -1172,7 +1172,7 @@ private: 785 lib::shared_ptr<proxy_data> m_proxy_data; 786 787 // transport resources 788- io_service_ptr m_io_service; 789+ io_context_ptr m_io_context; 790 strand_ptr m_strand; 791 connection_hdl m_connection_hdl; 792 793diff --git a/websocketpp/transport/asio/endpoint.hpp b/websocketpp/transport/asio/endpoint.hpp 794index 94509ad..7af0915 100644 795--- a/websocketpp/transport/asio/endpoint.hpp 796+++ b/websocketpp/transport/asio/endpoint.hpp 797@@ -77,25 +77,25 @@ public: 798 /// associated with this endpoint transport component 799 typedef typename transport_con_type::ptr transport_con_ptr; 800 801- /// Type of a pointer to the ASIO io_service being used 802- typedef lib::asio::io_service * io_service_ptr; 803+ /// Type of a pointer to the ASIO io_context being used 804+ typedef lib::asio::io_context * io_context_ptr; 805 /// Type of a shared pointer to the acceptor being used 806 typedef lib::shared_ptr<lib::asio::ip::tcp::acceptor> acceptor_ptr; 807 /// Type of a shared pointer to the resolver being used 808 typedef lib::shared_ptr<lib::asio::ip::tcp::resolver> resolver_ptr; 809 /// Type of timer handle 810 typedef lib::shared_ptr<lib::asio::steady_timer> timer_ptr; 811- /// Type of a shared pointer to an io_service work object 812- typedef lib::shared_ptr<lib::asio::io_service::work> work_ptr; 813+ /// Type of a shared pointer to an io_context work object 814+ typedef lib::shared_ptr<lib::asio::executor_work_guard<lib::asio::io_context::executor_type>> work_ptr; 815 816 /// Type of socket pre-bind handler 817 typedef lib::function<lib::error_code(acceptor_ptr)> tcp_pre_bind_handler; 818 819- // generate and manage our own io_service 820+ // generate and manage our own io_context 821 explicit endpoint() 822- : m_io_service(NULL) 823- , m_external_io_service(false) 824- , m_listen_backlog(lib::asio::socket_base::max_connections) 825+ : m_io_context(NULL) 826+ , m_external_io_context(false) 827+ , m_listen_backlog(lib::asio::socket_base::max_listen_connections) 828 , m_reuse_addr(false) 829 , m_state(UNINITIALIZED) 830 { 831@@ -103,14 +103,14 @@ public: 832 } 833 834 ~endpoint() { 835- // clean up our io_service if we were initialized with an internal one. 836+ // clean up our io_context if we were initialized with an internal one. 837 838 // Explicitly destroy local objects 839 m_acceptor.reset(); 840 m_resolver.reset(); 841 m_work.reset(); 842- if (m_state != UNINITIALIZED && !m_external_io_service) { 843- delete m_io_service; 844+ if (m_state != UNINITIALIZED && !m_external_io_context) { 845+ delete m_io_context; 846 } 847 } 848 849@@ -132,34 +132,34 @@ public: 850 : config::socket_type(std::move(src)) 851 , m_tcp_pre_init_handler(src.m_tcp_pre_init_handler) 852 , m_tcp_post_init_handler(src.m_tcp_post_init_handler) 853- , m_io_service(src.m_io_service) 854- , m_external_io_service(src.m_external_io_service) 855+ , m_io_context(src.m_io_context) 856+ , m_external_io_context(src.m_external_io_context) 857 , m_acceptor(src.m_acceptor) 858- , m_listen_backlog(lib::asio::socket_base::max_connections) 859+ , m_listen_backlog(lib::asio::socket_base::max_listen_connections) 860 , m_reuse_addr(src.m_reuse_addr) 861 , m_elog(src.m_elog) 862 , m_alog(src.m_alog) 863 , m_state(src.m_state) 864 { 865- src.m_io_service = NULL; 866- src.m_external_io_service = false; 867+ src.m_io_context = NULL; 868+ src.m_external_io_context = false; 869 src.m_acceptor = NULL; 870 src.m_state = UNINITIALIZED; 871 } 872 873 /*endpoint & operator= (const endpoint && rhs) { 874 if (this != &rhs) { 875- m_io_service = rhs.m_io_service; 876- m_external_io_service = rhs.m_external_io_service; 877+ m_io_context = rhs.m_io_context; 878+ m_external_io_context = rhs.m_external_io_context; 879 m_acceptor = rhs.m_acceptor; 880 m_listen_backlog = rhs.m_listen_backlog; 881 m_reuse_addr = rhs.m_reuse_addr; 882 m_state = rhs.m_state; 883 884- rhs.m_io_service = NULL; 885- rhs.m_external_io_service = false; 886+ rhs.m_io_context = NULL; 887+ rhs.m_external_io_context = false; 888 rhs.m_acceptor = NULL; 889- rhs.m_listen_backlog = lib::asio::socket_base::max_connections; 890+ rhs.m_listen_backlog = lib::asio::socket_base::max_listen_connections; 891 rhs.m_state = UNINITIALIZED; 892 893 // TODO: this needs to be updated 894@@ -173,16 +173,16 @@ public: 895 return socket_type::is_secure(); 896 } 897 898- /// initialize asio transport with external io_service (exception free) 899+ /// initialize asio transport with external io_context (exception free) 900 /** 901 * Initialize the ASIO transport policy for this endpoint using the provided 902- * io_service object. asio_init must be called exactly once on any endpoint 903+ * io_context object. asio_init must be called exactly once on any endpoint 904 * that uses transport::asio before it can be used. 905 * 906- * @param ptr A pointer to the io_service to use for asio events 907+ * @param ptr A pointer to the io_context to use for asio events 908 * @param ec Set to indicate what error occurred, if any. 909 */ 910- void init_asio(io_service_ptr ptr, lib::error_code & ec) { 911+ void init_asio(io_context_ptr ptr, lib::error_code & ec) { 912 if (m_state != UNINITIALIZED) { 913 m_elog->write(log::elevel::library, 914 "asio::init_asio called from the wrong state"); 915@@ -193,34 +193,34 @@ public: 916 917 m_alog->write(log::alevel::devel,"asio::init_asio"); 918 919- m_io_service = ptr; 920- m_external_io_service = true; 921- m_acceptor.reset(new lib::asio::ip::tcp::acceptor(*m_io_service)); 922+ m_io_context = ptr; 923+ m_external_io_context = true; 924+ m_acceptor.reset(new lib::asio::ip::tcp::acceptor(*m_io_context)); 925 926 m_state = READY; 927 ec = lib::error_code(); 928 } 929 930- /// initialize asio transport with external io_service 931+ /// initialize asio transport with external io_context 932 /** 933 * Initialize the ASIO transport policy for this endpoint using the provided 934- * io_service object. asio_init must be called exactly once on any endpoint 935+ * io_context object. asio_init must be called exactly once on any endpoint 936 * that uses transport::asio before it can be used. 937 * 938- * @param ptr A pointer to the io_service to use for asio events 939+ * @param ptr A pointer to the io_context to use for asio events 940 */ 941- void init_asio(io_service_ptr ptr) { 942+ void init_asio(io_context_ptr ptr) { 943 lib::error_code ec; 944 init_asio(ptr,ec); 945 if (ec) { throw exception(ec); } 946 } 947 948- /// Initialize asio transport with internal io_service (exception free) 949+ /// Initialize asio transport with internal io_context (exception free) 950 /** 951 * This method of initialization will allocate and use an internally managed 952- * io_service. 953+ * io_context. 954 * 955- * @see init_asio(io_service_ptr ptr) 956+ * @see init_asio(io_context_ptr ptr) 957 * 958 * @param ec Set to indicate what error occurred, if any. 959 */ 960@@ -230,21 +230,21 @@ public: 961 // TODO: remove the use of auto_ptr when C++98/03 support is no longer 962 // necessary. 963 #ifdef _WEBSOCKETPP_CPP11_MEMORY_ 964- lib::unique_ptr<lib::asio::io_service> service(new lib::asio::io_service()); 965+ lib::unique_ptr<lib::asio::io_context> context(new lib::asio::io_context()); 966 #else 967- lib::auto_ptr<lib::asio::io_service> service(new lib::asio::io_service()); 968+ lib::auto_ptr<lib::asio::io_context> context(new lib::asio::io_context()); 969 #endif 970- init_asio(service.get(), ec); 971- if( !ec ) service.release(); // Call was successful, transfer ownership 972- m_external_io_service = false; 973+ init_asio(context.get(), ec); 974+ if( !ec ) context.release(); // Call was successful, transfer ownership 975+ m_external_io_context = false; 976 } 977 978- /// Initialize asio transport with internal io_service 979+ /// Initialize asio transport with internal io_context 980 /** 981 * This method of initialization will allocate and use an internally managed 982- * io_service. 983+ * io_context. 984 * 985- * @see init_asio(io_service_ptr ptr) 986+ * @see init_asio(io_context_ptr ptr) 987 */ 988 void init_asio() { 989 // Use a smart pointer until the call is successful and ownership has 990@@ -252,14 +252,14 @@ public: 991 // TODO: remove the use of auto_ptr when C++98/03 support is no longer 992 // necessary. 993 #ifdef _WEBSOCKETPP_CPP11_MEMORY_ 994- lib::unique_ptr<lib::asio::io_service> service(new lib::asio::io_service()); 995+ lib::unique_ptr<lib::asio::io_context> context(new lib::asio::io_context()); 996 #else 997- lib::auto_ptr<lib::asio::io_service> service(new lib::asio::io_service()); 998+ lib::auto_ptr<lib::asio::io_context> context(new lib::asio::io_context()); 999 #endif 1000- init_asio( service.get() ); 1001+ init_asio( context.get() ); 1002 // If control got this far without an exception, then ownership has successfully been taken 1003- service.release(); 1004- m_external_io_service = false; 1005+ context.release(); 1006+ m_external_io_context = false; 1007 } 1008 1009 /// Sets the tcp pre bind handler 1010@@ -330,7 +330,7 @@ public: 1011 * 1012 * New values affect future calls to listen only. 1013 * 1014- * The default value is specified as *::asio::socket_base::max_connections 1015+ * The default value is specified as *::asio::socket_base::max_listen_connections 1016 * which uses the operating system defined maximum queue length. Your OS 1017 * may restrict or silently lower this value. A value of zero may cause 1018 * all connections to be rejected. 1019@@ -364,19 +364,19 @@ public: 1020 m_reuse_addr = value; 1021 } 1022 1023- /// Retrieve a reference to the endpoint's io_service 1024+ /// Retrieve a reference to the endpoint's io_context 1025 /** 1026- * The io_service may be an internal or external one. This may be used to 1027- * call methods of the io_service that are not explicitly wrapped by the 1028+ * The io_context may be an internal or external one. This may be used to 1029+ * call methods of the io_context that are not explicitly wrapped by the 1030 * endpoint. 1031 * 1032 * This method is only valid after the endpoint has been initialized with 1033 * `init_asio`. No error will be returned if it isn't. 1034 * 1035- * @return A reference to the endpoint's io_service 1036+ * @return A reference to the endpoint's io_context 1037 */ 1038- lib::asio::io_service & get_io_service() { 1039- return *m_io_service; 1040+ lib::asio::io_context & get_io_context() { 1041+ return *m_io_context; 1042 } 1043 1044 /// Get local TCP endpoint 1045@@ -557,17 +557,15 @@ public: 1046 lib::error_code & ec) 1047 { 1048 using lib::asio::ip::tcp; 1049- tcp::resolver r(*m_io_service); 1050- tcp::resolver::query query(host, service); 1051- tcp::resolver::iterator endpoint_iterator = r.resolve(query); 1052- tcp::resolver::iterator end; 1053- if (endpoint_iterator == end) { 1054+ tcp::resolver r(*m_io_context); 1055+ tcp::resolver::results_type endpoints = r.resolve(host, service); 1056+ if (endpoints.empty()) { 1057 m_elog->write(log::elevel::library, 1058 "asio::listen could not resolve the supplied host or service"); 1059 ec = make_error_code(error::invalid_host_service); 1060 return; 1061 } 1062- listen(*endpoint_iterator,ec); 1063+ listen(*endpoints.begin(),ec); 1064 } 1065 1066 /// Set up endpoint for listening on a host and service 1067@@ -636,42 +634,42 @@ public: 1068 return (m_state == LISTENING); 1069 } 1070 1071- /// wraps the run method of the internal io_service object 1072+ /// wraps the run method of the internal io_context object 1073 std::size_t run() { 1074- return m_io_service->run(); 1075+ return m_io_context->run(); 1076 } 1077 1078- /// wraps the run_one method of the internal io_service object 1079+ /// wraps the run_one method of the internal io_context object 1080 /** 1081 * @since 0.3.0-alpha4 1082 */ 1083 std::size_t run_one() { 1084- return m_io_service->run_one(); 1085+ return m_io_context->run_one(); 1086 } 1087 1088- /// wraps the stop method of the internal io_service object 1089+ /// wraps the stop method of the internal io_context object 1090 void stop() { 1091- m_io_service->stop(); 1092+ m_io_context->stop(); 1093 } 1094 1095- /// wraps the poll method of the internal io_service object 1096+ /// wraps the poll method of the internal io_context object 1097 std::size_t poll() { 1098- return m_io_service->poll(); 1099+ return m_io_context->poll(); 1100 } 1101 1102- /// wraps the poll_one method of the internal io_service object 1103+ /// wraps the poll_one method of the internal io_context object 1104 std::size_t poll_one() { 1105- return m_io_service->poll_one(); 1106+ return m_io_context->poll_one(); 1107 } 1108 1109- /// wraps the reset method of the internal io_service object 1110+ /// wraps the restart method of the internal io_context object 1111 void reset() { 1112- m_io_service->reset(); 1113+ m_io_context->restart(); 1114 } 1115 1116- /// wraps the stopped method of the internal io_service object 1117+ /// wraps the stopped method of the internal io_context object 1118 bool stopped() const { 1119- return m_io_service->stopped(); 1120+ return m_io_context->stopped(); 1121 } 1122 1123 /// Marks the endpoint as perpetual, stopping it from exiting when empty 1124@@ -687,7 +685,7 @@ public: 1125 * @since 0.3.0 1126 */ 1127 void start_perpetual() { 1128- m_work.reset(new lib::asio::io_service::work(*m_io_service)); 1129+ m_work.reset(new lib::asio::executor_work_guard<lib::asio::io_context::executor_type>(m_io_context->get_executor())); 1130 } 1131 1132 /// Clears the endpoint's perpetual flag, allowing it to exit when empty 1133@@ -716,7 +714,7 @@ public: 1134 */ 1135 timer_ptr set_timer(long duration, timer_handler callback) { 1136 timer_ptr new_timer = lib::make_shared<lib::asio::steady_timer>( 1137- *m_io_service, 1138+ *m_io_context, 1139 lib::asio::milliseconds(duration) 1140 ); 1141 1142@@ -851,7 +849,7 @@ protected: 1143 1144 // Create a resolver 1145 if (!m_resolver) { 1146- m_resolver.reset(new lib::asio::ip::tcp::resolver(*m_io_service)); 1147+ m_resolver.reset(new lib::asio::ip::tcp::resolver(*m_io_context)); 1148 } 1149 1150 tcon->set_uri(u); 1151@@ -883,8 +881,6 @@ protected: 1152 port = pu->get_port_str(); 1153 } 1154 1155- tcp::resolver::query query(host,port); 1156- 1157 if (m_alog->static_test(log::alevel::devel)) { 1158 m_alog->write(log::alevel::devel, 1159 "starting async DNS resolve for "+host+":"+port); 1160@@ -905,7 +901,8 @@ protected: 1161 1162 if (config::enable_multithreading) { 1163 m_resolver->async_resolve( 1164- query, 1165+ host, 1166+ port, 1167 tcon->get_strand()->wrap(lib::bind( 1168 &type::handle_resolve, 1169 this, 1170@@ -918,7 +915,8 @@ protected: 1171 ); 1172 } else { 1173 m_resolver->async_resolve( 1174- query, 1175+ host, 1176+ port, 1177 lib::bind( 1178 &type::handle_resolve, 1179 this, 1180@@ -966,10 +964,10 @@ protected: 1181 1182 void handle_resolve(transport_con_ptr tcon, timer_ptr dns_timer, 1183 connect_handler callback, lib::asio::error_code const & ec, 1184- lib::asio::ip::tcp::resolver::iterator iterator) 1185+ lib::asio::ip::tcp::resolver::results_type endpoints) 1186 { 1187 if (ec == lib::asio::error::operation_aborted || 1188- lib::asio::is_neg(dns_timer->expires_from_now())) 1189+ lib::asio::is_neg(dns_timer->expiry() - std::chrono::steady_clock::now())) 1190 { 1191 m_alog->write(log::alevel::devel,"async_resolve cancelled"); 1192 return; 1193@@ -987,8 +985,8 @@ protected: 1194 std::stringstream s; 1195 s << "Async DNS resolve successful. Results: "; 1196 1197- lib::asio::ip::tcp::resolver::iterator it, end; 1198- for (it = iterator; it != end; ++it) { 1199+ lib::asio::ip::tcp::resolver::results_type::iterator it; 1200+ for (it = endpoints.begin(); it != endpoints.end(); ++it) { 1201 s << (*it).endpoint() << " "; 1202 } 1203 1204@@ -1014,7 +1012,7 @@ protected: 1205 if (config::enable_multithreading) { 1206 lib::asio::async_connect( 1207 tcon->get_raw_socket(), 1208- iterator, 1209+ endpoints, 1210 tcon->get_strand()->wrap(lib::bind( 1211 &type::handle_connect, 1212 this, 1213@@ -1027,7 +1025,7 @@ protected: 1214 } else { 1215 lib::asio::async_connect( 1216 tcon->get_raw_socket(), 1217- iterator, 1218+ endpoints, 1219 lib::bind( 1220 &type::handle_connect, 1221 this, 1222@@ -1077,7 +1075,7 @@ protected: 1223 connect_handler callback, lib::asio::error_code const & ec) 1224 { 1225 if (ec == lib::asio::error::operation_aborted || 1226- lib::asio::is_neg(con_timer->expires_from_now())) 1227+ lib::asio::is_neg(con_timer->expiry() - std::chrono::steady_clock::now())) 1228 { 1229 m_alog->write(log::alevel::devel,"async_connect cancelled"); 1230 return; 1231@@ -1119,7 +1117,7 @@ protected: 1232 1233 lib::error_code ec; 1234 1235- ec = tcon->init_asio(m_io_service); 1236+ ec = tcon->init_asio(m_io_context); 1237 if (ec) {return ec;} 1238 1239 tcon->set_tcp_pre_init_handler(m_tcp_pre_init_handler); 1240@@ -1158,8 +1156,8 @@ private: 1241 tcp_init_handler m_tcp_post_init_handler; 1242 1243 // Network Resources 1244- io_service_ptr m_io_service; 1245- bool m_external_io_service; 1246+ io_context_ptr m_io_context; 1247+ bool m_external_io_context; 1248 acceptor_ptr m_acceptor; 1249 resolver_ptr m_resolver; 1250 work_ptr m_work; 1251diff --git a/websocketpp/transport/asio/security/none.hpp b/websocketpp/transport/asio/security/none.hpp 1252index 6c7d352..009063f 100644 1253--- a/websocketpp/transport/asio/security/none.hpp 1254+++ b/websocketpp/transport/asio/security/none.hpp 1255@@ -62,10 +62,10 @@ public: 1256 /// Type of a shared pointer to this connection socket component 1257 typedef lib::shared_ptr<type> ptr; 1258 1259- /// Type of a pointer to the Asio io_service being used 1260- typedef lib::asio::io_service* io_service_ptr; 1261- /// Type of a pointer to the Asio io_service strand being used 1262- typedef lib::shared_ptr<lib::asio::io_service::strand> strand_ptr; 1263+ /// Type of a pointer to the Asio io_context being used 1264+ typedef lib::asio::io_context* io_context_ptr; 1265+ /// Type of a pointer to the Asio io_context strand being used 1266+ typedef lib::shared_ptr<lib::asio::io_context::strand> strand_ptr; 1267 /// Type of the ASIO socket being used 1268 typedef lib::asio::ip::tcp::socket socket_type; 1269 /// Type of a shared pointer to the socket being used. 1270@@ -156,19 +156,19 @@ protected: 1271 /// Perform one time initializations 1272 /** 1273 * init_asio is called once immediately after construction to initialize 1274- * Asio components to the io_service 1275+ * Asio components to the io_context 1276 * 1277- * @param service A pointer to the endpoint's io_service 1278+ * @param service A pointer to the endpoint's io_context 1279 * @param strand A shared pointer to the connection's asio strand 1280 * @param is_server Whether or not the endpoint is a server or not. 1281 */ 1282- lib::error_code init_asio (io_service_ptr service, strand_ptr, bool) 1283+ lib::error_code init_asio (io_context_ptr context, strand_ptr, bool) 1284 { 1285 if (m_state != UNINITIALIZED) { 1286 return socket::make_error_code(socket::error::invalid_state); 1287 } 1288 1289- m_socket.reset(new lib::asio::ip::tcp::socket(*service)); 1290+ m_socket.reset(new lib::asio::ip::tcp::socket(*context)); 1291 1292 if (m_socket_init_handler) { 1293 m_socket_init_handler(m_hdl, *m_socket); 1294diff --git a/websocketpp/transport/asio/security/tls.hpp b/websocketpp/transport/asio/security/tls.hpp 1295index 04ac379..9f86fc1 100644 1296--- a/websocketpp/transport/asio/security/tls.hpp 1297+++ b/websocketpp/transport/asio/security/tls.hpp 1298@@ -71,10 +71,10 @@ public: 1299 typedef lib::asio::ssl::stream<lib::asio::ip::tcp::socket> socket_type; 1300 /// Type of a shared pointer to the ASIO socket being used 1301 typedef lib::shared_ptr<socket_type> socket_ptr; 1302- /// Type of a pointer to the ASIO io_service being used 1303- typedef lib::asio::io_service * io_service_ptr; 1304- /// Type of a pointer to the ASIO io_service strand being used 1305- typedef lib::shared_ptr<lib::asio::io_service::strand> strand_ptr; 1306+ /// Type of a pointer to the ASIO io_context being used 1307+ typedef lib::asio::io_context * io_context_ptr; 1308+ /// Type of a pointer to the ASIO io_context strand being used 1309+ typedef lib::shared_ptr<lib::asio::io_context::strand> strand_ptr; 1310 /// Type of a shared pointer to the ASIO TLS context being used 1311 typedef lib::shared_ptr<lib::asio::ssl::context> context_ptr; 1312 1313@@ -176,13 +176,13 @@ protected: 1314 /// Perform one time initializations 1315 /** 1316 * init_asio is called once immediately after construction to initialize 1317- * Asio components to the io_service 1318+ * Asio components to the io_context 1319 * 1320- * @param service A pointer to the endpoint's io_service 1321+ * @param service A pointer to the endpoint's io_context 1322 * @param strand A pointer to the connection's strand 1323 * @param is_server Whether or not the endpoint is a server or not. 1324 */ 1325- lib::error_code init_asio (io_service_ptr service, strand_ptr strand, 1326+ lib::error_code init_asio (io_context_ptr context, strand_ptr strand, 1327 bool is_server) 1328 { 1329 if (!m_tls_init_handler) { 1330@@ -193,13 +193,13 @@ protected: 1331 if (!m_context) { 1332 return socket::make_error_code(socket::error::invalid_tls_context); 1333 } 1334- m_socket.reset(new socket_type(*service, *m_context)); 1335+ m_socket.reset(new socket_type(*context, *m_context)); 1336 1337 if (m_socket_init_handler) { 1338 m_socket_init_handler(m_hdl, get_socket()); 1339 } 1340 1341- m_io_service = service; 1342+ m_io_context = context; 1343 m_strand = strand; 1344 m_is_server = is_server; 1345 1346@@ -381,7 +381,7 @@ private: 1347 } 1348 } 1349 1350- io_service_ptr m_io_service; 1351+ io_context_ptr m_io_context; 1352 strand_ptr m_strand; 1353 context_ptr m_context; 1354 socket_ptr m_socket; 1355diff --git a/websocketpp/transport/debug/endpoint.hpp b/websocketpp/transport/debug/endpoint.hpp 1356index adc89b3..3606441 100644 1357--- a/websocketpp/transport/debug/endpoint.hpp 1358+++ b/websocketpp/transport/debug/endpoint.hpp 1359@@ -60,7 +60,7 @@ public: 1360 /// associated connection transport component 1361 typedef typename transport_con_type::ptr transport_con_ptr; 1362 1363- // generate and manage our own io_service 1364+ // generate and manage our own io_context 1365 explicit endpoint() 1366 { 1367 //std::cout << "transport::iostream::endpoint constructor" << std::endl; 1368diff --git a/websocketpp/transport/iostream/endpoint.hpp b/websocketpp/transport/iostream/endpoint.hpp 1369index 14cba72..257472d 100644 1370--- a/websocketpp/transport/iostream/endpoint.hpp 1371+++ b/websocketpp/transport/iostream/endpoint.hpp 1372@@ -64,7 +64,7 @@ public: 1373 /// associated connection transport component 1374 typedef typename transport_con_type::ptr transport_con_ptr; 1375 1376- // generate and manage our own io_service 1377+ // generate and manage our own io_context 1378 explicit endpoint() : m_output_stream(NULL), m_is_secure(false) 1379 { 1380 //std::cout << "transport::iostream::endpoint constructor" << std::endl; 1381diff --git a/websocketpp/transport/stub/endpoint.hpp b/websocketpp/transport/stub/endpoint.hpp 1382index 3bbb78f..8f8493a 100644 1383--- a/websocketpp/transport/stub/endpoint.hpp 1384+++ b/websocketpp/transport/stub/endpoint.hpp 1385@@ -60,7 +60,7 @@ public: 1386 /// associated connection transport component 1387 typedef typename transport_con_type::ptr transport_con_ptr; 1388 1389- // generate and manage our own io_service 1390+ // generate and manage our own io_context 1391 explicit endpoint() 1392 { 1393 //std::cout << "transport::iostream::endpoint constructor" << std::endl; 1394-- 13952.48.1 1396 1397 1398From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 1399From: Amini Allight <amini.allight@protonmail.com> 1400Date: Wed, 12 Feb 2025 04:46:30 +0000 1401Subject: [PATCH 2/7] updated docstrings 1402 1403(cherry picked from commit 30e77468e093e8384fa07819b345f81a0431eb37) 1404 1405 Conflicts: 1406 websocketpp/transport/asio/endpoint.hpp 1407--- 1408 websocketpp/transport/asio/endpoint.hpp | 2 +- 1409 websocketpp/transport/asio/security/none.hpp | 2 +- 1410 websocketpp/transport/asio/security/tls.hpp | 2 +- 1411 3 files changed, 3 insertions(+), 3 deletions(-) 1412 1413diff --git a/websocketpp/transport/asio/endpoint.hpp b/websocketpp/transport/asio/endpoint.hpp 1414index 7af0915..a5e1700 100644 1415--- a/websocketpp/transport/asio/endpoint.hpp 1416+++ b/websocketpp/transport/asio/endpoint.hpp 1417@@ -549,7 +549,7 @@ public: 1418 * 1419 * @param host A string identifying a location. May be a descriptive name or 1420 * a numeric address string. 1421- * @param service A string identifying the requested service. This may be a 1422+ * @param context A string identifying the requested service. This may be a 1423 * descriptive name or a numeric string corresponding to a port number. 1424 * @param ec Set to indicate what error occurred, if any. 1425 */ 1426diff --git a/websocketpp/transport/asio/security/none.hpp b/websocketpp/transport/asio/security/none.hpp 1427index 009063f..ff19d5c 100644 1428--- a/websocketpp/transport/asio/security/none.hpp 1429+++ b/websocketpp/transport/asio/security/none.hpp 1430@@ -158,7 +158,7 @@ protected: 1431 * init_asio is called once immediately after construction to initialize 1432 * Asio components to the io_context 1433 * 1434- * @param service A pointer to the endpoint's io_context 1435+ * @param context A pointer to the endpoint's io_context 1436 * @param strand A shared pointer to the connection's asio strand 1437 * @param is_server Whether or not the endpoint is a server or not. 1438 */ 1439diff --git a/websocketpp/transport/asio/security/tls.hpp b/websocketpp/transport/asio/security/tls.hpp 1440index 9f86fc1..8b27656 100644 1441--- a/websocketpp/transport/asio/security/tls.hpp 1442+++ b/websocketpp/transport/asio/security/tls.hpp 1443@@ -178,7 +178,7 @@ protected: 1444 * init_asio is called once immediately after construction to initialize 1445 * Asio components to the io_context 1446 * 1447- * @param service A pointer to the endpoint's io_context 1448+ * @param context A pointer to the endpoint's io_context 1449 * @param strand A pointer to the connection's strand 1450 * @param is_server Whether or not the endpoint is a server or not. 1451 */ 1452-- 14532.48.1 1454 1455 1456From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 1457From: Amini Allight <amini.allight@protonmail.com> 1458Date: Wed, 12 Feb 2025 04:48:13 +0000 1459Subject: [PATCH 3/7] updated docstrings 1460 1461(cherry picked from commit 3d13472f7489bda718ded20d885dbaf98e36442c) 1462--- 1463 websocketpp/transport/asio/endpoint.hpp | 2 +- 1464 1 file changed, 1 insertion(+), 1 deletion(-) 1465 1466diff --git a/websocketpp/transport/asio/endpoint.hpp b/websocketpp/transport/asio/endpoint.hpp 1467index a5e1700..7af0915 100644 1468--- a/websocketpp/transport/asio/endpoint.hpp 1469+++ b/websocketpp/transport/asio/endpoint.hpp 1470@@ -549,7 +549,7 @@ public: 1471 * 1472 * @param host A string identifying a location. May be a descriptive name or 1473 * a numeric address string. 1474- * @param context A string identifying the requested service. This may be a 1475+ * @param service A string identifying the requested service. This may be a 1476 * descriptive name or a numeric string corresponding to a port number. 1477 * @param ec Set to indicate what error occurred, if any. 1478 */ 1479-- 14802.48.1 1481 1482 1483From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 1484From: Amini Allight <amini.allight@protonmail.com> 1485Date: Fri, 14 Feb 2025 07:48:42 +0000 1486Subject: [PATCH 4/7] silenced warning about unused variable in TLS IP address 1487 validation, improved time-to-expiry calculation (credit toonetown), added 1488 CMake flag to compile tests and examples with ASIO standalone, fixed example 1489 and test compilation with ASIO standalone 1490 1491(cherry picked from commit 6867ad089932fc2a786c39dae5ed152991e4ee46) 1492 1493 Conflicts: 1494 websocketpp/transport/asio/security/tls.hpp 1495--- 1496 CMakeLists.txt | 5 +++ 1497 examples/debug_client/debug_client.cpp | 12 +++--- 1498 .../echo_server_both/echo_server_both.cpp | 16 ++++---- 1499 .../external_io_context.cpp | 2 +- 1500 .../external_io_context/tcp_echo_server.hpp | 28 +++++++------- 1501 .../print_client_tls/print_client_tls.cpp | 14 +++---- 1502 examples/testee_server/testee_server.cpp | 4 +- 1503 test/endpoint/endpoint.cpp | 6 +-- 1504 test/http/parser_perf.cpp | 4 +- 1505 test/transport/asio/timers.cpp | 4 +- 1506 test/transport/integration.cpp | 38 ++++++++++--------- 1507 websocketpp/common/asio.hpp | 2 +- 1508 websocketpp/transport/asio/connection.hpp | 18 ++++----- 1509 websocketpp/transport/asio/endpoint.hpp | 4 +- 1510 14 files changed, 81 insertions(+), 76 deletions(-) 1511 1512diff --git a/CMakeLists.txt b/CMakeLists.txt 1513index 4f93e24..cde4273 100644 1514--- a/CMakeLists.txt 1515+++ b/CMakeLists.txt 1516@@ -75,6 +75,7 @@ include (CMakeHelpers) 1517 option (ENABLE_CPP11 "Build websocketpp with CPP11 features enabled." TRUE) 1518 option (BUILD_EXAMPLES "Build websocketpp examples." FALSE) 1519 option (BUILD_TESTS "Build websocketpp tests." FALSE) 1520+option (USE_ASIO_STANDALONE "Build websocketpp examples and tests using the standalone ASIO library." FALSE) 1521 1522 if (BUILD_TESTS OR BUILD_EXAMPLES) 1523 1524@@ -246,6 +247,10 @@ endif() 1525 1526 ############ Add projects 1527 1528+if (USE_ASIO_STANDALONE) 1529+ add_definitions("-DASIO_STANDALONE -DASIO_HAS_BOOST_DATE_TIME") 1530+endif () 1531+ 1532 # Add main library 1533 add_subdirectory (websocketpp) 1534 1535diff --git a/examples/debug_client/debug_client.cpp b/examples/debug_client/debug_client.cpp 1536index d3e21ab..7b6b40e 100644 1537--- a/examples/debug_client/debug_client.cpp 1538+++ b/examples/debug_client/debug_client.cpp 1539@@ -44,7 +44,7 @@ using websocketpp::lib::bind; 1540 1541 // pull out the type of messages sent by our config 1542 typedef websocketpp::config::asio_tls_client::message_type::ptr message_ptr; 1543-typedef websocketpp::lib::shared_ptr<boost::asio::ssl::context> context_ptr; 1544+typedef websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context> context_ptr; 1545 typedef client::connection_ptr connection_ptr; 1546 1547 1548@@ -94,13 +94,13 @@ public: 1549 1550 context_ptr on_tls_init(websocketpp::connection_hdl) { 1551 m_tls_init = std::chrono::high_resolution_clock::now(); 1552- context_ptr ctx = websocketpp::lib::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::tlsv1); 1553+ context_ptr ctx = websocketpp::lib::make_shared<websocketpp::lib::asio::ssl::context>(websocketpp::lib::asio::ssl::context::tlsv1); 1554 1555 try { 1556- ctx->set_options(boost::asio::ssl::context::default_workarounds | 1557- boost::asio::ssl::context::no_sslv2 | 1558- boost::asio::ssl::context::no_sslv3 | 1559- boost::asio::ssl::context::single_dh_use); 1560+ ctx->set_options(websocketpp::lib::asio::ssl::context::default_workarounds | 1561+ websocketpp::lib::asio::ssl::context::no_sslv2 | 1562+ websocketpp::lib::asio::ssl::context::no_sslv3 | 1563+ websocketpp::lib::asio::ssl::context::single_dh_use); 1564 } catch (std::exception& e) { 1565 std::cout << e.what() << std::endl; 1566 } 1567diff --git a/examples/echo_server_both/echo_server_both.cpp b/examples/echo_server_both/echo_server_both.cpp 1568index 869c006..a4f6a19 100644 1569--- a/examples/echo_server_both/echo_server_both.cpp 1570+++ b/examples/echo_server_both/echo_server_both.cpp 1571@@ -14,7 +14,7 @@ using websocketpp::lib::placeholders::_2; 1572 using websocketpp::lib::bind; 1573 1574 // type of the ssl context pointer is long so alias it 1575-typedef websocketpp::lib::shared_ptr<boost::asio::ssl::context> context_ptr; 1576+typedef websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context> context_ptr; 1577 1578 // The shared on_message handler takes a template parameter so the function can 1579 // resolve any endpoint dependent types like message_ptr or connection_ptr 1580@@ -41,16 +41,16 @@ std::string get_password() { 1581 1582 context_ptr on_tls_init(websocketpp::connection_hdl hdl) { 1583 std::cout << "on_tls_init called with hdl: " << hdl.lock().get() << std::endl; 1584- context_ptr ctx(new boost::asio::ssl::context(boost::asio::ssl::context::tlsv1)); 1585+ context_ptr ctx(new websocketpp::lib::asio::ssl::context(websocketpp::lib::asio::ssl::context::tlsv1)); 1586 1587 try { 1588- ctx->set_options(boost::asio::ssl::context::default_workarounds | 1589- boost::asio::ssl::context::no_sslv2 | 1590- boost::asio::ssl::context::no_sslv3 | 1591- boost::asio::ssl::context::single_dh_use); 1592+ ctx->set_options(websocketpp::lib::asio::ssl::context::default_workarounds | 1593+ websocketpp::lib::asio::ssl::context::no_sslv2 | 1594+ websocketpp::lib::asio::ssl::context::no_sslv3 | 1595+ websocketpp::lib::asio::ssl::context::single_dh_use); 1596 ctx->set_password_callback(bind(&get_password)); 1597 ctx->use_certificate_chain_file("server.pem"); 1598- ctx->use_private_key_file("server.pem", boost::asio::ssl::context::pem); 1599+ ctx->use_private_key_file("server.pem", websocketpp::lib::asio::ssl::context::pem); 1600 } catch (std::exception& e) { 1601 std::cout << e.what() << std::endl; 1602 } 1603@@ -60,7 +60,7 @@ context_ptr on_tls_init(websocketpp::connection_hdl hdl) { 1604 int main() { 1605 // set up an external io_context to run both endpoints on. This is not 1606 // strictly necessary, but simplifies thread management a bit. 1607- boost::asio::io_context ios; 1608+ websocketpp::lib::asio::io_context ios; 1609 1610 // set up plain endpoint 1611 server_plain endpoint_plain; 1612diff --git a/examples/external_io_context/external_io_context.cpp b/examples/external_io_context/external_io_context.cpp 1613index c5ba0a4..c6132ed 100644 1614--- a/examples/external_io_context/external_io_context.cpp 1615+++ b/examples/external_io_context/external_io_context.cpp 1616@@ -59,7 +59,7 @@ void on_message(ws_echo_server* s, websocketpp::connection_hdl hdl, ws_echo_serv 1617 } 1618 1619 int main() { 1620- asio::io_context context; 1621+ websocketpp::lib::asio::io_context context; 1622 1623 // Add a TCP echo server on port 9003 1624 tcp_echo_server custom_http_server(context, 9003); 1625diff --git a/examples/external_io_context/tcp_echo_server.hpp b/examples/external_io_context/tcp_echo_server.hpp 1626index 2e14703..f132c06 100644 1627--- a/examples/external_io_context/tcp_echo_server.hpp 1628+++ b/examples/external_io_context/tcp_echo_server.hpp 1629@@ -39,42 +39,40 @@ using websocketpp::lib::placeholders::_1; 1630 using websocketpp::lib::placeholders::_2; 1631 using websocketpp::lib::bind; 1632 1633-namespace asio = websocketpp::lib::asio; 1634- 1635 struct tcp_echo_session : websocketpp::lib::enable_shared_from_this<tcp_echo_session> { 1636 typedef websocketpp::lib::shared_ptr<tcp_echo_session> ptr; 1637 1638- tcp_echo_session(asio::io_context & context) : m_socket(context) {} 1639+ tcp_echo_session(websocketpp::lib::asio::io_context & context) : m_socket(context) {} 1640 1641 void start() { 1642- m_socket.async_read_some(asio::buffer(m_buffer, sizeof(m_buffer)), 1643+ m_socket.async_read_some(websocketpp::lib::asio::buffer(m_buffer, sizeof(m_buffer)), 1644 websocketpp::lib::bind( 1645 &tcp_echo_session::handle_read, shared_from_this(), _1, _2)); 1646 } 1647 1648- void handle_read(const asio::error_code & ec, size_t transferred) { 1649+ void handle_read(const websocketpp::lib::asio::error_code & ec, size_t transferred) { 1650 if (!ec) { 1651- asio::async_write(m_socket, 1652- asio::buffer(m_buffer, transferred), 1653+ websocketpp::lib::asio::async_write(m_socket, 1654+ websocketpp::lib::asio::buffer(m_buffer, transferred), 1655 bind(&tcp_echo_session::handle_write, shared_from_this(), _1)); 1656 } 1657 } 1658 1659- void handle_write(const asio::error_code & ec) { 1660+ void handle_write(const websocketpp::lib::asio::error_code & ec) { 1661 if (!ec) { 1662- m_socket.async_read_some(asio::buffer(m_buffer, sizeof(m_buffer)), 1663+ m_socket.async_read_some(websocketpp::lib::asio::buffer(m_buffer, sizeof(m_buffer)), 1664 bind(&tcp_echo_session::handle_read, shared_from_this(), _1, _2)); 1665 } 1666 } 1667 1668- asio::ip::tcp::socket m_socket; 1669+ websocketpp::lib::asio::ip::tcp::socket m_socket; 1670 char m_buffer[1024]; 1671 }; 1672 1673 struct tcp_echo_server { 1674- tcp_echo_server(asio::io_context & context, short port) 1675+ tcp_echo_server(websocketpp::lib::asio::io_context & context, short port) 1676 : m_context(context) 1677- , m_acceptor(context, asio::ip::tcp::endpoint(asio::ip::tcp::v6(), port)) 1678+ , m_acceptor(context, websocketpp::lib::asio::ip::tcp::endpoint(websocketpp::lib::asio::ip::tcp::v6(), port)) 1679 { 1680 this->start_accept(); 1681 } 1682@@ -85,13 +83,13 @@ struct tcp_echo_server { 1683 bind(&tcp_echo_server::handle_accept, this, new_session, _1)); 1684 } 1685 1686- void handle_accept(tcp_echo_session::ptr new_session, const asio::error_code & ec) { 1687+ void handle_accept(tcp_echo_session::ptr new_session, const websocketpp::lib::asio::error_code & ec) { 1688 if (!ec) { 1689 new_session->start(); 1690 } 1691 start_accept(); 1692 } 1693 1694- asio::io_context & m_context; 1695- asio::ip::tcp::acceptor m_acceptor; 1696+ websocketpp::lib::asio::io_context & m_context; 1697+ websocketpp::lib::asio::ip::tcp::acceptor m_acceptor; 1698 }; 1699diff --git a/examples/print_client_tls/print_client_tls.cpp b/examples/print_client_tls/print_client_tls.cpp 1700index 43164ea..cf616e1 100644 1701--- a/examples/print_client_tls/print_client_tls.cpp 1702+++ b/examples/print_client_tls/print_client_tls.cpp 1703@@ -112,7 +112,7 @@ bool verify_common_name(char const * hostname, X509 * cert) { 1704 * and 1705 * https://github.com/iSECPartners/ssl-conservatory 1706 */ 1707-bool verify_certificate(const char * hostname, bool preverified, boost::asio::ssl::verify_context& ctx) { 1708+bool verify_certificate(const char * hostname, bool preverified, websocketpp::lib::asio::ssl::verify_context& ctx) { 1709 // The verify callback can be used to check whether the certificate that is 1710 // being presented is valid for the peer. For example, RFC 2818 describes 1711 // the steps involved in doing this for HTTPS. Consult the OpenSSL 1712@@ -176,16 +176,16 @@ bool verify_certificate(const char * hostname, bool preverified, boost::asio::ss 1713 * (websocketpp.org, for example). 1714 */ 1715 context_ptr on_tls_init(const char * hostname, websocketpp::connection_hdl) { 1716- context_ptr ctx = websocketpp::lib::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::sslv23); 1717+ context_ptr ctx = websocketpp::lib::make_shared<websocketpp::lib::asio::ssl::context>(websocketpp::lib::asio::ssl::context::sslv23); 1718 1719 try { 1720- ctx->set_options(boost::asio::ssl::context::default_workarounds | 1721- boost::asio::ssl::context::no_sslv2 | 1722- boost::asio::ssl::context::no_sslv3 | 1723- boost::asio::ssl::context::single_dh_use); 1724+ ctx->set_options(websocketpp::lib::asio::ssl::context::default_workarounds | 1725+ websocketpp::lib::asio::ssl::context::no_sslv2 | 1726+ websocketpp::lib::asio::ssl::context::no_sslv3 | 1727+ websocketpp::lib::asio::ssl::context::single_dh_use); 1728 1729 1730- ctx->set_verify_mode(boost::asio::ssl::verify_peer); 1731+ ctx->set_verify_mode(websocketpp::lib::asio::ssl::verify_peer); 1732 ctx->set_verify_callback(bind(&verify_certificate, hostname, ::_1, ::_2)); 1733 1734 // Here we load the CA certificates of all CA's that this client trusts. 1735diff --git a/examples/testee_server/testee_server.cpp b/examples/testee_server/testee_server.cpp 1736index 13e574e..8920270 100644 1737--- a/examples/testee_server/testee_server.cpp 1738+++ b/examples/testee_server/testee_server.cpp 1739@@ -87,8 +87,8 @@ void on_message(server* s, websocketpp::connection_hdl hdl, message_ptr msg) { 1740 s->send(hdl, msg->get_payload(), msg->get_opcode()); 1741 } 1742 1743-void on_socket_init(websocketpp::connection_hdl, boost::asio::ip::tcp::socket & s) { 1744- boost::asio::ip::tcp::no_delay option(true); 1745+void on_socket_init(websocketpp::connection_hdl, websocketpp::lib::asio::ip::tcp::socket & s) { 1746+ websocketpp::lib::asio::ip::tcp::no_delay option(true); 1747 s.set_option(option); 1748 } 1749 1750diff --git a/test/endpoint/endpoint.cpp b/test/endpoint/endpoint.cpp 1751index fa58e66..c5f5a82 100644 1752--- a/test/endpoint/endpoint.cpp 1753+++ b/test/endpoint/endpoint.cpp 1754@@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE( initialize_server_asio ) { 1755 1756 BOOST_AUTO_TEST_CASE( initialize_server_asio_external ) { 1757 websocketpp::server<websocketpp::config::asio> s; 1758- boost::asio::io_context ios; 1759+ websocketpp::lib::asio::io_context ios; 1760 s.init_asio(&ios); 1761 } 1762 1763@@ -141,8 +141,8 @@ BOOST_AUTO_TEST_CASE( listen_after_listen_failure ) { 1764 server1.init_asio(); 1765 server2.init_asio(); 1766 1767- boost::asio::ip::tcp::endpoint ep1(boost::asio::ip::make_address("127.0.0.1"), 12345); 1768- boost::asio::ip::tcp::endpoint ep2(boost::asio::ip::make_address("127.0.0.1"), 23456); 1769+ websocketpp::lib::asio::ip::tcp::endpoint ep1(websocketpp::lib::asio::ip::make_address("127.0.0.1"), 12345); 1770+ websocketpp::lib::asio::ip::tcp::endpoint ep2(websocketpp::lib::asio::ip::make_address("127.0.0.1"), 23456); 1771 1772 server1.listen(ep1, ec); 1773 BOOST_CHECK(!ec); 1774diff --git a/test/http/parser_perf.cpp b/test/http/parser_perf.cpp 1775index 0c76bc7..0a9cc0b 100644 1776--- a/test/http/parser_perf.cpp 1777+++ b/test/http/parser_perf.cpp 1778@@ -31,11 +31,11 @@ 1779 1780 class scoped_timer { 1781 public: 1782- scoped_timer(std::string i) : m_id(i),m_start(std::chrono::steady_clock::now()) { 1783+ scoped_timer(std::string i) : m_id(i),m_start(timer_ptr::element_type::clock_type::now()) { 1784 std::cout << "Clock " << i << ": "; 1785 } 1786 ~scoped_timer() { 1787- std::chrono::nanoseconds time_taken = std::chrono::steady_clock::now()-m_start; 1788+ std::chrono::nanoseconds time_taken = timer_ptr::element_type::clock_type::now()-m_start; 1789 1790 //nanoseconds_per_test 1791 1792diff --git a/test/transport/asio/timers.cpp b/test/transport/asio/timers.cpp 1793index 391b755..d59654d 100644 1794--- a/test/transport/asio/timers.cpp 1795+++ b/test/transport/asio/timers.cpp 1796@@ -106,9 +106,9 @@ struct config { 1797 }; 1798 1799 // Mock context that does no validation 1800-typedef websocketpp::lib::shared_ptr<boost::asio::ssl::context> context_ptr; 1801+typedef websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context> context_ptr; 1802 context_ptr on_tls_init(websocketpp::connection_hdl) { 1803- return context_ptr(new boost::asio::ssl::context(boost::asio::ssl::context::sslv23)); 1804+ return context_ptr(new websocketpp::lib::asio::ssl::context(websocketpp::lib::asio::ssl::context::sslv23)); 1805 } 1806 1807 // Mock connection 1808diff --git a/test/transport/integration.cpp b/test/transport/integration.cpp 1809index ab82b1a..526b243 100644 1810--- a/test/transport/integration.cpp 1811+++ b/test/transport/integration.cpp 1812@@ -38,6 +38,8 @@ 1813 #include <websocketpp/server.hpp> 1814 #include <websocketpp/client.hpp> 1815 1816+#include "boost/date_time/posix_time/posix_time.hpp" 1817+ 1818 struct config : public websocketpp::config::asio_client { 1819 typedef config type; 1820 typedef websocketpp::config::asio base; 1821@@ -218,19 +220,19 @@ void run_time_limited_client(client & c, std::string uri, long timeout, 1822 } 1823 1824 void run_dummy_server(int port) { 1825- using boost::asio::ip::tcp; 1826+ using websocketpp::lib::asio::ip::tcp; 1827 1828 try { 1829- boost::asio::io_context io_context; 1830+ websocketpp::lib::asio::io_context io_context; 1831 tcp::acceptor acceptor(io_context, tcp::endpoint(tcp::v6(), port)); 1832 tcp::socket socket(io_context); 1833 1834 acceptor.accept(socket); 1835 for (;;) { 1836 char data[512]; 1837- boost::system::error_code ec; 1838- socket.read_some(boost::asio::buffer(data), ec); 1839- if (ec == boost::asio::error::eof) { 1840+ websocketpp::lib::asio::error_code ec; 1841+ socket.read_some(websocketpp::lib::asio::buffer(data), ec); 1842+ if (ec == websocketpp::lib::asio::error::eof) { 1843 break; 1844 } else if (ec) { 1845 // other error 1846@@ -239,26 +241,26 @@ void run_dummy_server(int port) { 1847 } 1848 } catch (std::exception & e) { 1849 std::cout << e.what() << std::endl; 1850- } catch (boost::system::error_code & ec) { 1851+ } catch (websocketpp::lib::asio::error_code & ec) { 1852 std::cout << ec.message() << std::endl; 1853 } 1854 } 1855 1856 void run_dummy_client(std::string port) { 1857- using boost::asio::ip::tcp; 1858+ using websocketpp::lib::asio::ip::tcp; 1859 1860 try { 1861- boost::asio::io_context io_context; 1862+ websocketpp::lib::asio::io_context io_context; 1863 tcp::resolver resolver(io_context); 1864 tcp::resolver::results_type endpoints = resolver.resolve("localhost", port); 1865 tcp::socket socket(io_context); 1866 1867- boost::asio::connect(socket, endpoints); 1868+ websocketpp::lib::asio::connect(socket, endpoints); 1869 for (;;) { 1870 char data[512]; 1871- boost::system::error_code ec; 1872- socket.read_some(boost::asio::buffer(data), ec); 1873- if (ec == boost::asio::error::eof) { 1874+ websocketpp::lib::asio::error_code ec; 1875+ socket.read_some(websocketpp::lib::asio::buffer(data), ec); 1876+ if (ec == websocketpp::lib::asio::error::eof) { 1877 break; 1878 } else if (ec) { 1879 // other error 1880@@ -267,7 +269,7 @@ void run_dummy_client(std::string port) { 1881 } 1882 } catch (std::exception & e) { 1883 std::cout << e.what() << std::endl; 1884- } catch (boost::system::error_code & ec) { 1885+ } catch (websocketpp::lib::asio::error_code & ec) { 1886 std::cout << ec.message() << std::endl; 1887 } 1888 } 1889@@ -360,7 +362,7 @@ public: 1890 : m_timer(m_io_context, boost::posix_time::seconds(seconds)) 1891 { 1892 m_timer.async_wait(bind(&test_deadline_timer::expired, this, ::_1)); 1893- std::size_t (boost::asio::io_context::*run)() = &boost::asio::io_context::run; 1894+ std::size_t (websocketpp::lib::asio::io_context::*run)() = &websocketpp::lib::asio::io_context::run; 1895 m_timer_thread = websocketpp::lib::thread(websocketpp::lib::bind(run, &m_io_context)); 1896 } 1897 ~test_deadline_timer() 1898@@ -370,16 +372,16 @@ public: 1899 } 1900 1901 private: 1902- void expired(const boost::system::error_code & ec) 1903+ void expired(const websocketpp::lib::asio::error_code & ec) 1904 { 1905- if (ec == boost::asio::error::operation_aborted) 1906+ if (ec == websocketpp::lib::asio::error::operation_aborted) 1907 return; 1908 BOOST_CHECK(!ec); 1909 BOOST_FAIL("Test timed out"); 1910 } 1911 1912- boost::asio::io_context m_io_context; 1913- boost::asio::deadline_timer m_timer; 1914+ websocketpp::lib::asio::io_context m_io_context; 1915+ websocketpp::lib::asio::deadline_timer m_timer; 1916 websocketpp::lib::thread m_timer_thread; 1917 }; 1918 1919diff --git a/websocketpp/common/asio.hpp b/websocketpp/common/asio.hpp 1920index 3c8fa13..7322c25 100644 1921--- a/websocketpp/common/asio.hpp 1922+++ b/websocketpp/common/asio.hpp 1923@@ -51,7 +51,7 @@ 1924 1925 #include <asio.hpp> 1926 #include <asio/steady_timer.hpp> 1927- #include <websocketpp/common/chrono.hpp> 1928+ #include <websocketpp/common/chrono.hpp> 1929 #else 1930 #include <boost/version.hpp> 1931 1932diff --git a/websocketpp/transport/asio/connection.hpp b/websocketpp/transport/asio/connection.hpp 1933index eaee6bc..d1a2c20 100644 1934--- a/websocketpp/transport/asio/connection.hpp 1935+++ b/websocketpp/transport/asio/connection.hpp 1936@@ -374,7 +374,7 @@ public: 1937 * fail handler is called. 1938 * 1939 * Primarily used if you are using mismatched asio / system_error 1940- * implementations such as `boost::asio` with `std::system_error`. In these 1941+ * implementations such as `lib::asio` with `std::system_error`. In these 1942 * cases the transport error type is different than the library error type 1943 * and some WebSocket++ functions that return transport errors via the 1944 * library error code type will be coerced into a catch all `pass_through` 1945@@ -573,7 +573,7 @@ protected: 1946 lib::error_code const & ec) 1947 { 1948 if (ec == transport::error::operation_aborted || 1949- (post_timer && lib::asio::is_neg(post_timer->expiry() - std::chrono::steady_clock::now()))) 1950+ (post_timer && lib::asio::is_neg(post_timer->expiry() - timer_ptr::element_type::clock_type::now()))) 1951 { 1952 m_alog->write(log::alevel::devel,"post_init cancelled"); 1953 return; 1954@@ -679,7 +679,7 @@ protected: 1955 // Whatever aborted it will be issuing the callback so we are safe to 1956 // return 1957 if (ec == lib::asio::error::operation_aborted || 1958- lib::asio::is_neg(m_proxy_data->timer->expiry() - std::chrono::steady_clock::now())) 1959+ lib::asio::is_neg(m_proxy_data->timer->expiry() - timer_ptr::element_type::clock_type::now())) 1960 { 1961 m_elog->write(log::elevel::devel,"write operation aborted"); 1962 return; 1963@@ -751,7 +751,7 @@ protected: 1964 // Whatever aborted it will be issuing the callback so we are safe to 1965 // return 1966 if (ec == lib::asio::error::operation_aborted || 1967- lib::asio::is_neg(m_proxy_data->timer->expiry() - std::chrono::steady_clock::now())) 1968+ lib::asio::is_neg(m_proxy_data->timer->expiry() - timer_ptr::element_type::clock_type::now())) 1969 { 1970 m_elog->write(log::elevel::devel,"read operation aborted"); 1971 return; 1972@@ -1012,18 +1012,18 @@ protected: 1973 */ 1974 lib::error_code interrupt(interrupt_handler handler) { 1975 if (config::enable_multithreading) { 1976- boost::asio::post(m_io_context->get_executor(), m_strand->wrap(handler)); 1977+ lib::asio::post(m_io_context->get_executor(), m_strand->wrap(handler)); 1978 } else { 1979- boost::asio::post(m_io_context->get_executor(), handler); 1980+ lib::asio::post(m_io_context->get_executor(), handler); 1981 } 1982 return lib::error_code(); 1983 } 1984 1985 lib::error_code dispatch(dispatch_handler handler) { 1986 if (config::enable_multithreading) { 1987- boost::asio::post(m_io_context->get_executor(), m_strand->wrap(handler)); 1988+ lib::asio::post(m_io_context->get_executor(), m_strand->wrap(handler)); 1989 } else { 1990- boost::asio::post(m_io_context->get_executor(), handler); 1991+ lib::asio::post(m_io_context->get_executor(), handler); 1992 } 1993 return lib::error_code(); 1994 } 1995@@ -1095,7 +1095,7 @@ protected: 1996 callback, lib::asio::error_code const & ec) 1997 { 1998 if (ec == lib::asio::error::operation_aborted || 1999- lib::asio::is_neg(shutdown_timer->expiry() - std::chrono::steady_clock::now())) 2000+ lib::asio::is_neg(shutdown_timer->expiry() - timer_ptr::element_type::clock_type::now())) 2001 { 2002 m_alog->write(log::alevel::devel,"async_shutdown cancelled"); 2003 return; 2004diff --git a/websocketpp/transport/asio/endpoint.hpp b/websocketpp/transport/asio/endpoint.hpp 2005index 7af0915..57f784f 100644 2006--- a/websocketpp/transport/asio/endpoint.hpp 2007+++ b/websocketpp/transport/asio/endpoint.hpp 2008@@ -967,7 +967,7 @@ protected: 2009 lib::asio::ip::tcp::resolver::results_type endpoints) 2010 { 2011 if (ec == lib::asio::error::operation_aborted || 2012- lib::asio::is_neg(dns_timer->expiry() - std::chrono::steady_clock::now())) 2013+ lib::asio::is_neg(dns_timer->expiry() - timer_ptr::element_type::clock_type::now())) 2014 { 2015 m_alog->write(log::alevel::devel,"async_resolve cancelled"); 2016 return; 2017@@ -1075,7 +1075,7 @@ protected: 2018 connect_handler callback, lib::asio::error_code const & ec) 2019 { 2020 if (ec == lib::asio::error::operation_aborted || 2021- lib::asio::is_neg(con_timer->expiry() - std::chrono::steady_clock::now())) 2022+ lib::asio::is_neg(con_timer->expiry() - timer_ptr::element_type::clock_type::now())) 2023 { 2024 m_alog->write(log::alevel::devel,"async_connect cancelled"); 2025 return; 2026-- 20272.48.1 2028 2029 2030From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2031From: Amini Allight <amini.allight@protonmail.com> 2032Date: Fri, 14 Feb 2025 23:13:38 +0000 2033Subject: [PATCH 5/7] improved variable names and fixed comments 2034 2035(cherry picked from commit dbdde20a9b4ffd49f480fd9e6e29ea212a73253b) 2036 2037 Conflicts: 2038 websocketpp/transport/asio/endpoint.hpp 2039--- 2040 .../echo_server_both/echo_server_both.cpp | 8 +++--- 2041 test/endpoint/endpoint.cpp | 4 +-- 2042 test/transport/asio/timers.cpp | 4 +-- 2043 test/transport/integration.cpp | 4 +-- 2044 websocketpp/transport/asio/connection.hpp | 2 +- 2045 websocketpp/transport/asio/endpoint.hpp | 27 +++++++++---------- 2046 6 files changed, 24 insertions(+), 25 deletions(-) 2047 2048diff --git a/examples/echo_server_both/echo_server_both.cpp b/examples/echo_server_both/echo_server_both.cpp 2049index a4f6a19..886ea7f 100644 2050--- a/examples/echo_server_both/echo_server_both.cpp 2051+++ b/examples/echo_server_both/echo_server_both.cpp 2052@@ -60,12 +60,12 @@ context_ptr on_tls_init(websocketpp::connection_hdl hdl) { 2053 int main() { 2054 // set up an external io_context to run both endpoints on. This is not 2055 // strictly necessary, but simplifies thread management a bit. 2056- websocketpp::lib::asio::io_context ios; 2057+ websocketpp::lib::asio::io_context ctx; 2058 2059 // set up plain endpoint 2060 server_plain endpoint_plain; 2061 // initialize asio with our external io_context rather than an internal one 2062- endpoint_plain.init_asio(&ios); 2063+ endpoint_plain.init_asio(&ctx); 2064 endpoint_plain.set_message_handler( 2065 bind(&on_message<server_plain>,&endpoint_plain,::_1,::_2)); 2066 endpoint_plain.listen(80); 2067@@ -73,7 +73,7 @@ int main() { 2068 2069 // set up tls endpoint 2070 server_tls endpoint_tls; 2071- endpoint_tls.init_asio(&ios); 2072+ endpoint_tls.init_asio(&ctx); 2073 endpoint_tls.set_message_handler( 2074 bind(&on_message<server_tls>,&endpoint_tls,::_1,::_2)); 2075 // TLS endpoint has an extra handler for the tls init 2076@@ -83,5 +83,5 @@ int main() { 2077 endpoint_tls.start_accept(); 2078 2079 // Start the ASIO io_context run loop running both endpoints 2080- ios.run(); 2081+ ctx.run(); 2082 } 2083diff --git a/test/endpoint/endpoint.cpp b/test/endpoint/endpoint.cpp 2084index c5f5a82..1840278 100644 2085--- a/test/endpoint/endpoint.cpp 2086+++ b/test/endpoint/endpoint.cpp 2087@@ -53,8 +53,8 @@ BOOST_AUTO_TEST_CASE( initialize_server_asio ) { 2088 2089 BOOST_AUTO_TEST_CASE( initialize_server_asio_external ) { 2090 websocketpp::server<websocketpp::config::asio> s; 2091- websocketpp::lib::asio::io_context ios; 2092- s.init_asio(&ios); 2093+ websocketpp::lib::asio::io_context ctx; 2094+ s.init_asio(&ctx); 2095 } 2096 2097 #ifdef _WEBSOCKETPP_MOVE_SEMANTICS_ 2098diff --git a/test/transport/asio/timers.cpp b/test/transport/asio/timers.cpp 2099index d59654d..84938cb 100644 2100--- a/test/transport/asio/timers.cpp 2101+++ b/test/transport/asio/timers.cpp 2102@@ -79,8 +79,8 @@ void run_dummy_server(int port) { 2103 2104 // Wait for the specified time period then fail the test 2105 void run_test_timer(long value) { 2106- boost::asio::io_context ios; 2107- boost::asio::deadline_timer t(ios,boost::posix_time::milliseconds(value)); 2108+ boost::asio::io_context ctx; 2109+ boost::asio::deadline_timer t(ctx,boost::posix_time::milliseconds(value)); 2110 boost::system::error_code ec; 2111 t.wait(ec); 2112 BOOST_FAIL( "Test timed out" ); 2113diff --git a/test/transport/integration.cpp b/test/transport/integration.cpp 2114index 526b243..371c554 100644 2115--- a/test/transport/integration.cpp 2116+++ b/test/transport/integration.cpp 2117@@ -252,10 +252,10 @@ void run_dummy_client(std::string port) { 2118 try { 2119 websocketpp::lib::asio::io_context io_context; 2120 tcp::resolver resolver(io_context); 2121- tcp::resolver::results_type endpoints = resolver.resolve("localhost", port); 2122+ tcp::resolver::results_type results = resolver.resolve("localhost", port); 2123 tcp::socket socket(io_context); 2124 2125- websocketpp::lib::asio::connect(socket, endpoints); 2126+ websocketpp::lib::asio::connect(socket, results); 2127 for (;;) { 2128 char data[512]; 2129 websocketpp::lib::asio::error_code ec; 2130diff --git a/websocketpp/transport/asio/connection.hpp b/websocketpp/transport/asio/connection.hpp 2131index d1a2c20..f4c13f3 100644 2132--- a/websocketpp/transport/asio/connection.hpp 2133+++ b/websocketpp/transport/asio/connection.hpp 2134@@ -374,7 +374,7 @@ public: 2135 * fail handler is called. 2136 * 2137 * Primarily used if you are using mismatched asio / system_error 2138- * implementations such as `lib::asio` with `std::system_error`. In these 2139+ * implementations such as `boost::asio` with `std::system_error`. In these 2140 * cases the transport error type is different than the library error type 2141 * and some WebSocket++ functions that return transport errors via the 2142 * library error code type will be coerced into a catch all `pass_through` 2143diff --git a/websocketpp/transport/asio/endpoint.hpp b/websocketpp/transport/asio/endpoint.hpp 2144index 57f784f..2aafd67 100644 2145--- a/websocketpp/transport/asio/endpoint.hpp 2146+++ b/websocketpp/transport/asio/endpoint.hpp 2147@@ -86,7 +86,7 @@ public: 2148 /// Type of timer handle 2149 typedef lib::shared_ptr<lib::asio::steady_timer> timer_ptr; 2150 /// Type of a shared pointer to an io_context work object 2151- typedef lib::shared_ptr<lib::asio::executor_work_guard<lib::asio::io_context::executor_type>> work_ptr; 2152+ typedef lib::shared_ptr<lib::asio::executor_work_guard<lib::asio::io_context::executor_type>> work_guard_ptr; 2153 2154 /// Type of socket pre-bind handler 2155 typedef lib::function<lib::error_code(acceptor_ptr)> tcp_pre_bind_handler; 2156@@ -108,7 +108,7 @@ public: 2157 // Explicitly destroy local objects 2158 m_acceptor.reset(); 2159 m_resolver.reset(); 2160- m_work.reset(); 2161+ m_work_guard.reset(); 2162 if (m_state != UNINITIALIZED && !m_external_io_context) { 2163 delete m_io_context; 2164 } 2165@@ -541,8 +541,7 @@ public: 2166 /** 2167 * Bind the internal acceptor using the given host and service. More details 2168 * about what host and service can be are available in the Asio 2169- * documentation for ip::basic_resolver_query::basic_resolver_query's 2170- * constructors. 2171+ * documentation for the ip::basic_resolver::resolve function. 2172 * 2173 * The endpoint must have been initialized by calling init_asio before 2174 * listening. 2175@@ -558,14 +557,14 @@ public: 2176 { 2177 using lib::asio::ip::tcp; 2178 tcp::resolver r(*m_io_context); 2179- tcp::resolver::results_type endpoints = r.resolve(host, service); 2180- if (endpoints.empty()) { 2181+ tcp::resolver::results_type results = r.resolve(host, service); 2182+ if (results.empty()) { 2183 m_elog->write(log::elevel::library, 2184 "asio::listen could not resolve the supplied host or service"); 2185 ec = make_error_code(error::invalid_host_service); 2186 return; 2187 } 2188- listen(*endpoints.begin(),ec); 2189+ listen(*(results.begin()),ec); 2190 } 2191 2192 /// Set up endpoint for listening on a host and service 2193@@ -685,7 +684,7 @@ public: 2194 * @since 0.3.0 2195 */ 2196 void start_perpetual() { 2197- m_work.reset(new lib::asio::executor_work_guard<lib::asio::io_context::executor_type>(m_io_context->get_executor())); 2198+ m_work_guard.reset(new lib::asio::executor_work_guard<lib::asio::io_context::executor_type>(m_io_context->get_executor())); 2199 } 2200 2201 /// Clears the endpoint's perpetual flag, allowing it to exit when empty 2202@@ -697,7 +696,7 @@ public: 2203 * @since 0.3.0 2204 */ 2205 void stop_perpetual() { 2206- m_work.reset(); 2207+ m_work_guard.reset(); 2208 } 2209 2210 /// Call back a function after a period of time. 2211@@ -964,7 +963,7 @@ protected: 2212 2213 void handle_resolve(transport_con_ptr tcon, timer_ptr dns_timer, 2214 connect_handler callback, lib::asio::error_code const & ec, 2215- lib::asio::ip::tcp::resolver::results_type endpoints) 2216+ lib::asio::ip::tcp::resolver::results_type results) 2217 { 2218 if (ec == lib::asio::error::operation_aborted || 2219 lib::asio::is_neg(dns_timer->expiry() - timer_ptr::element_type::clock_type::now())) 2220@@ -986,7 +985,7 @@ protected: 2221 s << "Async DNS resolve successful. Results: "; 2222 2223 lib::asio::ip::tcp::resolver::results_type::iterator it; 2224- for (it = endpoints.begin(); it != endpoints.end(); ++it) { 2225+ for (it = results.begin(); it != results.end(); ++it) { 2226 s << (*it).endpoint() << " "; 2227 } 2228 2229@@ -1012,7 +1011,7 @@ protected: 2230 if (config::enable_multithreading) { 2231 lib::asio::async_connect( 2232 tcon->get_raw_socket(), 2233- endpoints, 2234+ results, 2235 tcon->get_strand()->wrap(lib::bind( 2236 &type::handle_connect, 2237 this, 2238@@ -1025,7 +1024,7 @@ protected: 2239 } else { 2240 lib::asio::async_connect( 2241 tcon->get_raw_socket(), 2242- endpoints, 2243+ results, 2244 lib::bind( 2245 &type::handle_connect, 2246 this, 2247@@ -1160,7 +1159,7 @@ private: 2248 bool m_external_io_context; 2249 acceptor_ptr m_acceptor; 2250 resolver_ptr m_resolver; 2251- work_ptr m_work; 2252+ work_guard_ptr m_work_guard; 2253 2254 // Network constants 2255 int m_listen_backlog; 2256-- 22572.48.1 2258 2259 2260From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2261From: Amini Allight <amini.allight@protonmail.com> 2262Date: Thu, 20 Feb 2025 06:19:46 +0000 2263Subject: [PATCH 6/7] fixed use of deprecated boost::asio::deadline_timer in 2264 tests 2265 2266(cherry picked from commit 096487461fe834c30fb322ac0b9088ad82e5a2d5) 2267--- 2268 test/transport/asio/timers.cpp | 3 ++- 2269 test/transport/integration.cpp | 27 ++++++++++++++------------- 2270 2 files changed, 16 insertions(+), 14 deletions(-) 2271 2272diff --git a/test/transport/asio/timers.cpp b/test/transport/asio/timers.cpp 2273index 84938cb..22a4bba 100644 2274--- a/test/transport/asio/timers.cpp 2275+++ b/test/transport/asio/timers.cpp 2276@@ -80,7 +80,8 @@ void run_dummy_server(int port) { 2277 // Wait for the specified time period then fail the test 2278 void run_test_timer(long value) { 2279 boost::asio::io_context ctx; 2280- boost::asio::deadline_timer t(ctx,boost::posix_time::milliseconds(value)); 2281+ boost::asio::system_timer t(ctx); 2282+ t.expires_after(std::chrono::milliseconds(value)); 2283 boost::system::error_code ec; 2284 t.wait(ec); 2285 BOOST_FAIL( "Test timed out" ); 2286diff --git a/test/transport/integration.cpp b/test/transport/integration.cpp 2287index 371c554..70f4442 100644 2288--- a/test/transport/integration.cpp 2289+++ b/test/transport/integration.cpp 2290@@ -355,17 +355,18 @@ void close(T * e, websocketpp::connection_hdl hdl) { 2291 e->get_con_from_hdl(hdl)->close(websocketpp::close::status::normal,""); 2292 } 2293 2294-class test_deadline_timer 2295+class test_system_timer 2296 { 2297 public: 2298- test_deadline_timer(int seconds) 2299- : m_timer(m_io_context, boost::posix_time::seconds(seconds)) 2300+ test_system_timer(int seconds) 2301+ : m_timer(m_io_context) 2302 { 2303- m_timer.async_wait(bind(&test_deadline_timer::expired, this, ::_1)); 2304+ m_timer.expires_after(std::chrono::seconds(seconds)); 2305+ m_timer.async_wait(bind(&test_system_timer::expired, this, ::_1)); 2306 std::size_t (websocketpp::lib::asio::io_context::*run)() = &websocketpp::lib::asio::io_context::run; 2307 m_timer_thread = websocketpp::lib::thread(websocketpp::lib::bind(run, &m_io_context)); 2308 } 2309- ~test_deadline_timer() 2310+ ~test_system_timer() 2311 { 2312 m_timer.cancel(); 2313 m_timer_thread.join(); 2314@@ -381,7 +382,7 @@ public: 2315 } 2316 2317 websocketpp::lib::asio::io_context m_io_context; 2318- websocketpp::lib::asio::deadline_timer m_timer; 2319+ websocketpp::lib::asio::system_timer m_timer; 2320 websocketpp::lib::thread m_timer_thread; 2321 }; 2322 2323@@ -427,7 +428,7 @@ BOOST_AUTO_TEST_CASE( pong_timeout ) { 2324 websocketpp::lib::thread sthread(websocketpp::lib::bind(&run_server,&s,9005,false)); 2325 sleep(1); // give the server thread some time to start 2326 2327- test_deadline_timer deadline(10); 2328+ test_system_timer deadline(10); 2329 2330 run_client(c, "http://localhost:9005",false); 2331 2332@@ -448,7 +449,7 @@ BOOST_AUTO_TEST_CASE( client_open_handshake_timeout ) { 2333 2334 sleep(1); // give the server thread some time to start 2335 2336- test_deadline_timer deadline(10); 2337+ test_system_timer deadline(10); 2338 2339 run_client(c, "http://localhost:9005"); 2340 } 2341@@ -464,7 +465,7 @@ BOOST_AUTO_TEST_CASE( server_open_handshake_timeout ) { 2342 2343 websocketpp::lib::thread sthread(websocketpp::lib::bind(&run_server,&s,9005,false)); 2344 2345- test_deadline_timer deadline(10); 2346+ test_system_timer deadline(10); 2347 2348 sleep(1); // give the server thread some time to start 2349 2350@@ -489,7 +490,7 @@ BOOST_AUTO_TEST_CASE( client_self_initiated_close_handshake_timeout ) { 2351 2352 websocketpp::lib::thread sthread(websocketpp::lib::bind(&run_server,&s,9005,false)); 2353 2354- test_deadline_timer deadline(10); 2355+ test_system_timer deadline(10); 2356 2357 sleep(1); // give the server thread some time to start 2358 2359@@ -522,7 +523,7 @@ BOOST_AUTO_TEST_CASE( server_self_initiated_close_handshake_timeout ) { 2360 c.set_open_handler(bind(&delay,::_1,1)); 2361 2362 websocketpp::lib::thread sthread(websocketpp::lib::bind(&run_server,&s,9005,false)); 2363- test_deadline_timer deadline(10); 2364+ test_system_timer deadline(10); 2365 2366 sleep(1); // give the server thread some time to start 2367 2368@@ -534,7 +535,7 @@ BOOST_AUTO_TEST_CASE( server_self_initiated_close_handshake_timeout ) { 2369 BOOST_AUTO_TEST_CASE( client_runs_out_of_work ) { 2370 client c; 2371 2372- test_deadline_timer deadline(3); 2373+ test_system_timer deadline(3); 2374 2375 websocketpp::lib::error_code ec; 2376 c.init_asio(ec); 2377@@ -600,7 +601,7 @@ BOOST_AUTO_TEST_CASE( stop_listening ) { 2378 c.set_open_handler(bind(&close<client>,&c,::_1)); 2379 2380 websocketpp::lib::thread sthread(websocketpp::lib::bind(&run_server,&s,9005,false)); 2381- test_deadline_timer deadline(5); 2382+ test_system_timer deadline(5); 2383 2384 sleep(1); // give the server thread some time to start 2385 2386-- 23872.48.1 2388 2389 2390From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2391From: Amini Allight <amini.allight@protonmail.com> 2392Date: Thu, 20 Feb 2025 17:25:03 +0000 2393Subject: [PATCH 7/7] replaced uses of boost::asio::io_context::strand::wrap 2394 with boost::asio::bind_executor to avoid future deprecation issues 2395 2396(cherry picked from commit a11fa6fe4937ca251753e90b1836a68bf57768a9) 2397--- 2398 websocketpp/transport/asio/connection.hpp | 16 ++++++++-------- 2399 websocketpp/transport/asio/endpoint.hpp | 6 +++--- 2400 websocketpp/transport/asio/security/tls.hpp | 4 ++-- 2401 3 files changed, 13 insertions(+), 13 deletions(-) 2402 2403diff --git a/websocketpp/transport/asio/connection.hpp b/websocketpp/transport/asio/connection.hpp 2404index f4c13f3..4baa2ea 100644 2405--- a/websocketpp/transport/asio/connection.hpp 2406+++ b/websocketpp/transport/asio/connection.hpp 2407@@ -318,7 +318,7 @@ public: 2408 ); 2409 2410 if (config::enable_multithreading) { 2411- new_timer->async_wait(m_strand->wrap(lib::bind( 2412+ new_timer->async_wait(lib::asio::bind_executor(*m_strand, lib::bind( 2413 &type::handle_timer, get_shared(), 2414 new_timer, 2415 callback, 2416@@ -629,7 +629,7 @@ protected: 2417 lib::asio::async_write( 2418 socket_con_type::get_next_layer(), 2419 m_bufs, 2420- m_strand->wrap(lib::bind( 2421+ lib::asio::bind_executor(*m_strand, lib::bind( 2422 &type::handle_proxy_write, get_shared(), 2423 callback, 2424 lib::placeholders::_1 2425@@ -713,7 +713,7 @@ protected: 2426 socket_con_type::get_next_layer(), 2427 m_proxy_data->read_buf, 2428 "\r\n\r\n", 2429- m_strand->wrap(lib::bind( 2430+ lib::asio::bind_executor(*m_strand, lib::bind( 2431 &type::handle_proxy_read, get_shared(), 2432 callback, 2433 lib::placeholders::_1, lib::placeholders::_2 2434@@ -841,7 +841,7 @@ protected: 2435 socket_con_type::get_socket(), 2436 lib::asio::buffer(buf,len), 2437 lib::asio::transfer_at_least(num_bytes), 2438- m_strand->wrap(make_custom_alloc_handler( 2439+ lib::asio::bind_executor(*m_strand, make_custom_alloc_handler( 2440 m_read_handler_allocator, 2441 lib::bind( 2442 &type::handle_async_read, get_shared(), 2443@@ -910,7 +910,7 @@ protected: 2444 lib::asio::async_write( 2445 socket_con_type::get_socket(), 2446 m_bufs, 2447- m_strand->wrap(make_custom_alloc_handler( 2448+ lib::asio::bind_executor(*m_strand, make_custom_alloc_handler( 2449 m_write_handler_allocator, 2450 lib::bind( 2451 &type::handle_async_write, get_shared(), 2452@@ -947,7 +947,7 @@ protected: 2453 lib::asio::async_write( 2454 socket_con_type::get_socket(), 2455 m_bufs, 2456- m_strand->wrap(make_custom_alloc_handler( 2457+ lib::asio::bind_executor(*m_strand, make_custom_alloc_handler( 2458 m_write_handler_allocator, 2459 lib::bind( 2460 &type::handle_async_write, get_shared(), 2461@@ -1012,7 +1012,7 @@ protected: 2462 */ 2463 lib::error_code interrupt(interrupt_handler handler) { 2464 if (config::enable_multithreading) { 2465- lib::asio::post(m_io_context->get_executor(), m_strand->wrap(handler)); 2466+ lib::asio::post(m_io_context->get_executor(), lib::asio::bind_executor(*m_strand, handler)); 2467 } else { 2468 lib::asio::post(m_io_context->get_executor(), handler); 2469 } 2470@@ -1021,7 +1021,7 @@ protected: 2471 2472 lib::error_code dispatch(dispatch_handler handler) { 2473 if (config::enable_multithreading) { 2474- lib::asio::post(m_io_context->get_executor(), m_strand->wrap(handler)); 2475+ lib::asio::post(m_io_context->get_executor(), lib::asio::bind_executor(*m_strand, handler)); 2476 } else { 2477 lib::asio::post(m_io_context->get_executor(), handler); 2478 } 2479diff --git a/websocketpp/transport/asio/endpoint.hpp b/websocketpp/transport/asio/endpoint.hpp 2480index 2aafd67..b9e1ae8 100644 2481--- a/websocketpp/transport/asio/endpoint.hpp 2482+++ b/websocketpp/transport/asio/endpoint.hpp 2483@@ -776,7 +776,7 @@ public: 2484 if (config::enable_multithreading) { 2485 m_acceptor->async_accept( 2486 tcon->get_raw_socket(), 2487- tcon->get_strand()->wrap(lib::bind( 2488+ lib::asio::bind_executor(*tcon->get_strand(), lib::bind( 2489 &type::handle_accept, 2490 this, 2491 callback, 2492@@ -902,7 +902,7 @@ protected: 2493 m_resolver->async_resolve( 2494 host, 2495 port, 2496- tcon->get_strand()->wrap(lib::bind( 2497+ lib::asio::bind_executor(*tcon->get_strand(), lib::bind( 2498 &type::handle_resolve, 2499 this, 2500 tcon, 2501@@ -1012,7 +1012,7 @@ protected: 2502 lib::asio::async_connect( 2503 tcon->get_raw_socket(), 2504 results, 2505- tcon->get_strand()->wrap(lib::bind( 2506+ lib::asio::bind_executor(*tcon->get_strand(), lib::bind( 2507 &type::handle_connect, 2508 this, 2509 tcon, 2510diff --git a/websocketpp/transport/asio/security/tls.hpp b/websocketpp/transport/asio/security/tls.hpp 2511index 8b27656..07651c0 100644 2512--- a/websocketpp/transport/asio/security/tls.hpp 2513+++ b/websocketpp/transport/asio/security/tls.hpp 2514@@ -266,7 +266,7 @@ protected: 2515 if (m_strand) { 2516 m_socket->async_handshake( 2517 get_handshake_type(), 2518- m_strand->wrap(lib::bind( 2519+ lib::asio::bind_executor(*m_strand, lib::bind( 2520 &type::handle_init, get_shared(), 2521 callback, 2522 lib::placeholders::_1 2523@@ -326,7 +326,7 @@ protected: 2524 2525 void async_shutdown(socket::shutdown_handler callback) { 2526 if (m_strand) { 2527- m_socket->async_shutdown(m_strand->wrap(callback)); 2528+ m_socket->async_shutdown(lib::asio::bind_executor(*m_strand, callback)); 2529 } else { 2530 m_socket->async_shutdown(callback); 2531 } 2532-- 25332.48.1 2534