
I posted an async_accept to my io_service. The async_accept gets posted again to listen for incoming connections every time it completes. I was under the impression that calling io_service::stop, would be the way to stop listening. When debugging, I see that a function object was created when I called bind inside my async_accept call. That function object contains a smart pointer to the instance of the object to whom the method to call back belongs. Since the callback never happens, my instance never gets destroyed. How do I effectively cancel any outstanding work the io_service has posted to it, such that the smart pointer in the function object that the bind created will lose its reference count? In debugging, the callback never gets called after stop, not does the reference count in the smart pointer decrement.