Boost logo

Boost Users :

Subject: Re: [Boost-users] stop thread before socket destructor
From: Gianni Ambrosio (gianni.ambrosio_at_[hidden])
Date: 2011-04-28 05:11:45

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

I added a member variable:

boost::asio::io_service::work work_;

I instanciated it in the server constructor as follows:


Then in the server destructor:


That seems working and the handle_accept is never called after the


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at