[Libwebsockets] FYI: qpid-dispatch project now has websocket integration using libwebsockets
andy at warmcat.com
Fri Dec 2 17:07:27 CET 2016
On December 2, 2016 9:49:22 PM GMT+08:00, Alan Conway <aconway at redhat.com> wrote:
>On Fri, 2016-12-02 at 03:47 +0800, Andy Green wrote:
>> > wrote:
>> > sec delay before CLOSED but that isn't a problem if it's expected
>> > behavior. Now to embed a http server :)
>> I really recommend using the "mount" support in v2.0+. Basically you
>> bind a directory to a 'mountpoint' in the url space, and lws takes
>> care of all the serving without your having to provide any related
>> callback handlers. There's a test-server-v2.0.c that shows how to
>> register a linked-list of mounts when creating a vhost.
>I got it working with callbacks but I'll switch to mount, my noddy HTTP
>server is probably not very HTTP-compliant :)
>I still need to know when a socket goes into a HUP or error state so I
>can take it out of my poll loop while LWS is doing timeouts etc. before
>finally closing it. Is there a way to do that with the mount option? If
No, mounts (basically automated handling for chunks of url space) are unrelated to socketfd state. Mounts happen at a layer above.
>not I can fix it from my end, but so far I've been managing that from
>the LWS callbacks.
You still get most user callbacks with mounts. It just takes care of http payload callbacks itself if the url space matches a mountpoint. So if what you do in the callbacks is outside of the http callbacks, it should continue to be called / work.
>Next up SSL (and maybe a bit of protocol sniffing) and we will be ready
If you are doing the SSL outside of / before lws, that might be trouble; there are no arrangements as it stands to adopt the connection's SSL object set up by foreign code as there is for the foreign socket fd. But if you do ALL SSL outside lws, and still just pass plaintext buffers in and out of lws, maybe it's ok (setting up and using openssl from scratch on the foreign side is not that trivial though).
More information about the Libwebsockets