There is this SO answer
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.