Boost logo

Boost :

From: Arvid Norberg (arvid.norberg_at_[hidden])
Date: 2020-08-26 15:19:44


On Wed, Aug 26, 2020 at 2:51 PM Matthias Loy via Boost <
boost_at_[hidden]> 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_/polymorphic_socket.hpp

-- 
Arvid Norberg

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk