On Fri, Apr 6, 2018 at 7:29 AM, Alexander D. via Boost-users
Yes, I do need the program to work on at least Windows XP.
This restriction described in the Boost.Asio documentation places constrains on how your code may be designed: "[CancelIO] will only cancel asynchronous operations that were initiated in the current thread." This means you must always use an implicit strand (only one thread calling io_service::run), and always call initiating functions from it, especially the call to the first initiating function (which is often made from a foreign thread). The call to cancel() must of course be made from the io_service thread (asio sockets are not thread safe), which can be done by using boost::asio::post if you are on a foreign thread. If you need your application service connections using more than one thread you will need to use one io_service per thread.
Why can't we shutdown a stream while reading from it (since we can close a socket while reading)?
If you insist on supporting a defective operating system, then do not be surprised if things don't work the way you want. From the Boost.Asio documentation (RE: CancelIO on Windows XP): "[CancelIO] can appear to complete without error, but the request to cancel the unfinished operations may be silently ignored by the operating system. Whether it works or not seems to depend on the drivers that are installed." So, IF you make sure only one thread is used on each instance of io_service , AND your user has cooperative drivers, then MAYBE your program will function correctly. Regards