Boost logo

Boost :

From: Darryl Green (Darryl.Green_at_[hidden])
Date: 2002-11-26 19:47:04


> From: Boris Schäling [mailto:boris_at_[hidden]]
> Sent: Wednesday, 27 November 2002 3:12 AM
> > From: boost-bounces_at_[hidden]
> > [mailto:boost-bounces_at_[hidden]]On Behalf Of Hamish Mackenzie
> >
> > How does the multiplexor know what to pass to write the second time?
>
> The multiplexor doesn't know but the stream does. The multiplexor calls
> stream::write() when the socket descriptor is writable. The stream calls
> ::write() and sends all data which was saved in the stream's buffer
> because
> of EWOULDBLOCK to the network.
>
> +-------------+ +--------------+ 1) +--------------+
> | multiplexor | 2) | stream |<-------| observer |
> | |<-------| | | |
> | | 3) | | | |
> | |------->| | | |
> +-------------+ +--------------+ +--------------+
>
> 1) observer calls stream::writen() to send data.
> 2) stream calls multiplexor::set_write() because of EWOULDBLOCK.
> 3) multiplexor calls stream::write() when the socket descriptor is
> writable.
>
>
> > What if I want to send a live video stream?
>
> Good point. There is currently no UDP support in my library. Maybe traits
> could be used to tell the stream to discard data that couldn't be written
> immediately? I am not sure if anything else had to be changed for UDP?
>
I really think a lower level/more flexible interface than the one you propose needs to be provided if the concept is generalised beyond common "socket" types (which is necessary, to me at least, that's why we have written one - unfortunately I can't provide source). Even with the more common socket types, there are some interesting usages to consider as Hamish suggests. Out lib uses a very simple interface but we have written stream interfaces similar to what you describe on top of that, which are used where appropriate, but it certainly isn't the only interface we have found useful/needed.

Regards
Darryl


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