On Tue, 11 Oct 2022, 09:22 Richard Hodges via Boost-users, < boost-users@lists.boost.org> wrote:
On Tue, 11 Oct 2022 at 01:51, Ivan Matek via Boost-users < boost-users@lists.boost.org> wrote:
There is this SO answer https://stackoverflow.com/a/25703699/ with Vinnie comment from 8y ago that it should be added to documentation. :) I can not find anything in the documentation so I presume the documentation/example does not exist, but I decided to double check.
There are three methods on the asio socket interface that will be relevant:
- The destructor, which calls close() internally - the close() method, which calls shutdown() internally - you can think of this as a passthrough to an underlying posix close() function call but with an extra important step. - the shutdown() method which you can think of as a passthrough to the underlying bsd sockets shutdown() function.
Calling close() will cause all outstanding IO operations to immediately post completion with an error code
Therefore any of the above will cause all outstanding IO on the socket to post their completion handlers to the associated executor.
That explanation seems to ignore that the SSL path is a layer on top of sockets with its own buffers that live inside the ssl stream type. The ssl stream destruction is quite badly handled by asio, there are instances where asio will still attempt to write data to ssl stream buffers even after the associated stream has been destructed.