0

I was reading the boost websocket example here. In the listener class, it initializes the socket_ object. After listener accepted the connection, the socket_ is being std::move to the session object. I didn't see any logic to recreate the socket_ object. When the listener accept another connection, would it be an issue?

user926958
  • 9,355
  • 7
  • 28
  • 33
  • Have a look at [this topic](https://stackoverflow.com/questions/17715794/repeated-stdmove-on-an-boostasio-socket-object-in-c11). See Igor R's answer. – rafix07 Sep 18 '19 at 04:51

1 Answers1

0

The only question you need to ask is: Is the state of a socket_ invalid after moving it to a session? The answer is no.

After moving a socket object, it basically is reset to its original state, as if newly constructed.

The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189