Reputation: 1401
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?
Upvotes: 10
Views: 11269
Reputation: 170
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)
Upvotes: 1
Reputation: 1401
Since ASIO v 1.13 new I/O object can be constructed using just the executor:
socket new_socket{existing_socket.get_executor()};
Upvotes: 3
Reputation: 16334
You can use get_executor().context()
:
socket newSocket(existingSocket.get_executor().context()));
Upvotes: 6