[Boost.Asio] Can I move io_context away while having sockets bound to it?

You created serveral sockets and bound them to an io_context Is it safe to std::move the io_context away? Will those sockets be affected, or even be invalidated?

On Tue, 22 Mar 2022 at 08:09, B Aleck via Boost-users < boost-users@lists.boost.org> wrote:
Is it safe to std::move the io_context away?
It's not a matter of safety. It's just impossible, an io_context is not movable (or copyable): https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/io_conte...

On Tue, 22 Mar 2022 at 09:42, Cristian Morales Vega via Boost-users < boost-users@lists.boost.org> wrote:
On Tue, 22 Mar 2022 at 08:09, B Aleck via Boost-users < boost-users@lists.boost.org> wrote:
Is it safe to std::move the io_context away?
It's not a matter of safety. It's just impossible, an io_context is not movable (or copyable): https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/io_conte...
As a side note, if you want something moveable, use the io_context's executor. It is both moveable and cheaply copyable. Amongst other things, it acts as a handle to the underlying io_context.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
B Aleck
-
Cristian Morales Vega
-
Richard Hodges