projects/guix·blob python-team · refs

2612 lines · 119.3 KiB

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