[Libwebsockets] polling for file descriptor i/o
andy at warmcat.com
Wed Mar 1 22:33:28 CET 2017
On March 2, 2017 6:07:35 AM GMT+09:00, Per Bothner <per at bothner.com> wrote:
>I tried using lws_adopt_descriptor_vhost:
> lws_adopt_descriptor_vhost(lws_get_vhost(wsi), 0, fd, "domterm");
>I do get a LWS_CALLBACK_RAW_RX_FILE callback, and I can read valid
>data from thefrom the pty.
>However, the 'user' parameter in the callback function is NULL.
>I kludged around it using a static variable, but I need a better
>solution, obviously. Could/should lws_adopt_descriptor_vhost
>take an extra user_data parameter?
We can do that, or have it allocate (and free) based on the user data size given in the protocols struct... does the latter make any trouble if we fixed it that way?
>In case LWS_CALLBACK_RAW_RX_FILE I read the data into a buffer, and
>call lws_callback_on_writable(wsi). I do *not* get a
>event; instead I get a LWS_CALLBACK_RAW_WRITEABLE_FILE. Calling
That bit is good... you might have the same protocol callback handling ws and raw file side, so they have different callback reasons.
>in a LWS_CALLBACK_RAW_WRITEABLE_FILE fails.
... but this isn't I guess it's some missing handling somewhere.
Is there a clue what happens? You should use LWS_WRITE_HTTP as it stands (nearest thing to raw atm)
More information about the Libwebsockets