id summary reporter owner description type status milestone component version severity resolution keywords cc 13477 Initializing boost::asio socket after constructor failed nguyen.tnhoang@… chris_kohlhoff "I create a class to broadcast UDP messages as in the attached socket.cpp file. It works fine. Then, I wish to initialize the socket after the class constructor is initialized (to allow user input). So, I change from using socket to a socket pointer as in the socketPtr.cpp. It is a solution suggested by this post (https://stackoverflow.com/questions/31371214/initializing-boostasio-sockets-after-constructor). The replacements are as follows, where io_service is wrapped as boost::ref(io_service): //boost::asio::ip::udp::socket socket; boost::shared_ptr socketPtr; //boost::asio::ip::udp::socket socket(io_service, endpoint.protocol()); //socket.set_option(boost::asio::ip::udp::socket::reuse_address(true)); socketPtr = boost::make_shared(boost::ref(io_service), endpoint.protocol()); socketPtr->set_option(boost::asio::ip::udp::socket::reuse_address(true)); //socket.async_send_to(boost::asio::buffer(message), endpoint, [this](boost::system::error_code ec, std::size_t /*length*/) socketPtr->async_send_to(boost::asio::buffer(message), endpoint, [this](boost::system::error_code ec, std::size_t /*length*/) Just one thing with the modification: it doesn't work. I keep poring over the code, and could not find the reason why it shouldn't work. Could someone please help?" Bugs new To Be Determined asio Boost 1.66.0 Showstopper c++ asio boost shared_ptr boost::ref