Il 4/28/2011 12:21 AM, Igor R ha scritto:
Now, how could I stop the thread in the server destructor so that the handle_accept is not called anymore? You can wait until io_service::run() exits:
~stream_handler() { acceptor_.close();
//... thread_.join(); }
I think that would not prevent the handle_accept to be called after the server destructor, with an error code related to the message I told you in the previous email. I find a solution in a different way, using the boost::asio::io_service::work. I added a member variable: boost::asio::io_service::work work_; I instanciated it in the server constructor as follows: work_(io_service_) Then in the server destructor: ~stream_handler() { io_service_.stop(); } That seems working and the handle_accept is never called after the destructor. Thanks, Gianni