How do I cleanly reconnect a boost::socket following a disconnect?
You need to create a new boost::asio::ip::tcp::socket each time you reconnect. The easiest way to do this is probably to just allocate the socket on the heap using a boost::shared_ptr (you could probably also get away with scoped_ptr if your socket is entirely encapsulated within a class). E.g.: bool MyClient::myconnect() { bool isConnected = false; … Read more