On Thu, Dec 20, 2018 at 6:45 PM Richard Hodges
...even with Vinnie's easy to follow guide, it requires a hundred lines of boilerplate to implement what amounts to one async method.
Yes, that is kind of irritating. I've been working on some tools to make it easier. The function wrap_handler returns a new completion handler which wraps your function object (lambda) and inherits the allocator and executor of another completion handler: https://github.com/vinniefalco/beast/blob/8afbc6090bded0cdfda46871d829ea778a... The class template base_handler<> is meant as a base class for composed operations, it holds the handler for you and it provides all the hooks. I notice that you didn't include an overload for asio_handler_invoke in your example, which will certainly cause undefined behavior in some cases: https://github.com/vinniefalco/beast/blob/8afbc6090bded0cdfda46871d829ea778a... You can see both wrap_handler and handler_base used together to implement a composed operation, a flavor of async_read_some which has a built-in timeout: https://github.com/vinniefalco/beast/blob/8afbc6090bded0cdfda46871d829ea778a... In particular, handler_base let me leave out all of the boilerplate which is nice. It is possible that with some adaptation these utilities can be used to achieve the result you desire. These experimental features will appear in Boost.Beast version 1.70.0. Regards