[Libwebsockets] libwebsockets integration in zeroMQ zloop or libev, anyone?

"Andy Green (林安廸)" andy at warmcat.com
Sat May 11 17:27:25 CEST 2013

On 11/05/13 20:05, the mail apparently from Michael Haberler included:
> Hi,
> I'm investigating integration of libwebsockets into a zeroMQ (actually czmq) event loop, as well as libev (different use case)
> the issue I have is:
> - libwebsockets assumes there is a poll(2) call in the external event loop and relies on the pollfds data structure
> - this is not a given with czmq (or libev for that matter) which might use one of a series of different event notification mechanism: poll,epoll, select, kqueue etc
> - czmq deals with the issue by abstracting the actual system call arguments by providing its own event notification data structure, zmq_pollitem_t (see http://api.zeromq.org/3-2:zmq-poll)
> - libev does this in a very similar way with struct ev_watcher
> I'm unsure how to do this without butchering up the library code proper, which I'd prefer to avoid
> I'd be happy with a stopgap measure for now
> wouldnt it be better long term to remove the assumption of a particular underlying system call altogether?

I hope you can get some ideas from Edwin's code, but generally although 
the interface to lws is using pollfds, how you implement it in your 
external code is up to you.

So long as you fake up a pollfds to get it serviced by the library, it 
should remain blissfully ignorant as to how you heard that fd had 
something happen.

Whatever you do use needs something at least as flexible as 
POLLIN/OUT/ERR and revents, other than that it shouldn't care.


More information about the Libwebsockets mailing list