[Libwebsockets] polling for file descriptor i/o
per at bothner.com
Sat Mar 4 22:59:01 CET 2017
On 03/04/2017 12:14 PM, Andy Green wrote:
>> The flow should be
>> - notified of rx on file fd
>> - set the parent flag and ask for writeable callback on parent
>> - lws_rx_flow_control(wsi, 0); to disable POLLIN / rx notifications
>> - notified of parent writeable
>> - read child and send data
>> - lws_rx_flow_control(wsi_child, 1); to allow more rx on child file fd
I tried that, and I haven't gotten it to work. However:
> Dunno if it is interesting, but eventually you might also want to look at the mirror test protocol approach as well
> He supports one-to-many by adding a FIFO that is fed in the file fd RX (the read happens right there in this approach) and the ws clients draw down the fifo at their own speeds. RX flow control is only used then to protect the fifo from overflowing.
> That way you can offer sharing the pty remotely to n clients.
Long-term, I would like to include the functionality of the 'screen'
program, including detachable and multi-user sessions. However, it will
have to wait. For one, it depends on me understand certificates and
related security issues better. For another, there are other "big"
features I want to focus on first (better input editing a la readline;
a builtin less-like pager).
But this does suggest that having the read from the pty fd be to be done in RAW_RX_FILE callback
(not the SERVER_WRITEABLE callback) might be the more future-proof approach.
Plus the little detail that I actually have that working ...
per at bothner.com http://per.bothner.com/
More information about the Libwebsockets