chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.89k stars 1.21k forks source link

what kind of executor has a socket that has been moved from? #1329

Open travnick opened 1 year ago

travnick commented 1 year ago

Boost Asio sockets are moveable as documentation says

https://www.boost.org/doc/libs/1_81_0/doc/html/boost_asio/overview/cpp2011/move_objects.html

But there is no information how it behaves is original executor is wrapped with strand https://www.boost.org/doc/libs/1_81_0/doc/html/boost_asio/reference/basic_stream_socket/basic_stream_socket/overload9.html https://www.boost.org/doc/libs/1_81_0/doc/html/boost_asio/reference/strand/strand/overload5.html

So I did create a socket, with strand and then moved from it.

boost::asio::io_context context;
boost::asio::ip::tcp::socket socket1{make_strand(context)};
boost::asio::ip::tcp::socket socket2{std::move(socket1)};

I assume that since move took place, then socket2 is simply a socket1 (before move).

The question is what is the executor of socket1?:

Is there any documentation of this case?

--edited at 14:41 on 2023-07-18 because of misspell the socket1/socket2