[Libwebsockets] polling for file descriptor i/o

Andy Green andy at warmcat.com
Sun Feb 26 20:37:55 CET 2017

On February 27, 2017 1:27:04 AM GMT+09:00, Per Bothner <per at bothner.com> wrote:
>On 02/20/2017 04:59 PM, Andy Green wrote:
>> On 02/19/2017 05:32 AM, Andy Green wrote:
>>> On 02/18/2017 01:45 AM, Per Bothner wrote:
>>>> Is there any mechanism to add a file descriptor to the lws event
>>>> loop and have a callback function fire when data arrives?
>>>> Perhaps this could use a new pseudo-protocol?
>> I pushed an untested patch adding this on master.
>> The deal with it is there is a new adoption api
>> struct lws *
>> lws_adopt_socket_vhost2(struct lws_vhost *vh, lws_sockfd_type
>>             int allow_ssl, int raw)
>> this lets you control whether ssl will apply (if the vhost is set up
>for it), and if the adoption is for a raw socket.
>> If allow ssl and the vhost is configured for it, then lws will
>negotiate the ssl link on the connection first.
>> The wsi experiences these callbacks
>> ...
>> once it's adopted lws owns the fate of the socket fd including
>logical closing of it.  Otherwise it should hopefully work as you would
>I'm not understanding how this help.  I don't have a "foreign socket" -

It helps people who do have a foreign socket that is not in http protocol, like this other guy I linked to.  I thought your problem was the same.

>I have a "foreign file descriptor".  Specifically a pseudoterminal
>I understand that (in Unix at least) a socket is a file descriptor;
>however, a file descriptor is not necessarily a socket.

Okay, now you explain, I understand.

How about you also explain what kind of semantics you are looking for from lws around that fd to save us having another round of "that's not what I need"?


More information about the Libwebsockets mailing list