[Libwebsockets] polling for file descriptor i/o

Per Bothner per at bothner.com
Sun Feb 26 17:27:04 CET 2017

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 accept_fd,
>             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 expect.

I'm not understanding how this help.  I don't have a "foreign socket" -
I have a "foreign file descriptor".  Specifically a pseudoterminal master.
I understand that (in Unix at least) a socket is a file descriptor;
however, a file descriptor is not necessarily a socket.
	--Per Bothner
per at bothner.com   http://per.bothner.com/

More information about the Libwebsockets mailing list