On 6 April 2018 at 16:29, Alexander D. via Boost-users <boost-users@lists.boost.org> wrote:
On April 6, 2018 9:55 PM, Vinnie Falco via Boost-users <boost-users@lists.boost.org> wrote:
> On Fri, Apr 6, 2018 at 6:11 AM, Alexander D. via Boost-users
> <boost-users@lists.boost.org> wrote:
>>>> The only solution I can think of would be to cancel the read operation, but there's no portable way in asio to do this.
>>>
>>>     sock.next_layer().cancel();
>>>
>>> ?
>>
>> Per ASIO Reference:
>>
>> "Calls to cancel() will always fail with boost::asio::error::operation_not_supported when run on Windows XP, Windows Server 2003, and earlier versions of Windows, unless BOOST_ASIO_ENABLE_CANCELIO is defined. However, the CancelIo function has two issues that should be considered before enabling its use:
>> ..."
>>
>> which renders cancel() non-portable.
>
> I consider the issues with cancel present in Windows XP and Windows
> Server 2003 to be sufficiently problematic that it is not worth taking
> them into account when designing robust network applications (I do
> develop mostly on Windows). Unless you have a specific business need
> to support those defective operating systems, I would just ignore
> them.

Yes, I do need the program to work on at least Windows XP.

However, even if cancel() is used, it is a workaround, not a solution. If you run the code I supplied, you'll notice that async_read_some() is actually finished with a "stream truncated" error, quite similar to "canceling" the read. The problem is on async_shutdown()'s handler not being called, and it's not mentioned anywhere in the reference. Why can't we shutdown a stream while reading from it (since we can close a socket while reading)?

In the past, when I have had queries about the inner workings and design decisions behind ASIO, I have emailed the author, Chris Karloff. I am sure he is a busy guy but he has taken the trouble to answer helpfully in the past. It may be worth dropping him a line and asking for a suggestion.

He didn't charge me but having received help twice now, I think it would be rude of me not to offer him a few hours consultancy if I needed his help again. 

https://think-async.com/Asio/CommercialSupport



 
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users