Asio v 1.11. The doc says that basic_stream_socket::get_io_service() member function is deprecated and get_executor() must be used instead. But the latter returns executor not io_service.
How to obtain reference to the io_service object used by socket to construct another one?
You can use get_executor().context():
socket newSocket(existingSocket.get_executor().context()));
Since ASIO v 1.13 new I/O object can be constructed using just the executor:
socket new_socket{existing_socket.get_executor()};
Since I don't have enough reputation points to comment, I write as an answer:
Using get_executor().context() did not work right away for me, but writing a macro did (see this answer)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With