There's a `generic` protocol type in ASIO that type-erases the protocol, rather than the stream itself. You only pay for it when manipulating the endpoint, not when performing async ops, here's an example of how to use it: https://godbolt.org/z/T6Tjdh On Wed, Aug 26, 2020 at 5:20 PM Arvid Norberg via Boost < boost@lists.boost.org> wrote:
On Wed, Aug 26, 2020 at 2:51 PM Matthias Loy via Boost < boost@lists.boost.org> wrote:
[...] All those protocols are streaming protocols and should behave in the same way: read some bytes, write some bytes.
Websocket is a stream of messages, but I suppose you could ignore the message boundaries and treat each message as a section of a stream.
[...] Until now I was not able to find something like base classes that allow me to do that. I only found code that works for tcp or unix domain sockets (local). The protocol is not to be decided at compile time but on runtime. Hence I'm having problems using templates here.
The documentation of async_read states that the stream has to support the AsyncReadStream concept. Is there a way to get something supporting this concept from local::stream_protocol::socket and ip::tcp::socket?
You could do something along these lines, to wrap a std::variant<> of different concrete socket types.
https://github.com/arvidn/libtorrent/blob/master/include/libtorrent/aux_/pol...
-- Arvid Norberg
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost