libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] Websockets


From: John Duncan
Subject: Re: [libmicrohttpd] Websockets
Date: Fri, 17 Mar 2017 14:44:51 -1000

Websockets and RFC6455.  I noticed the test_upgrade.c unit test code doesn't provide the accept handshake key combination hashing specified on page 8 of the RFC, in the section "opening handshake." 

Apparently we're supposed to combine the websocket key with a predesignated static GUID, hash it, and send it back.  Without doing this, current firefox refuses to accept a websocket connection to MHD. 


My question is, should I write this functionality myself or are there plans for MHD to implement it in the future with macros or such?  It seems very easy to implement but I don't want to implement my own code if the library has plans to implement this functionality for users directly.  Don't want to duplicate efforts etc.

Thanks;
~JM

On Mon, Mar 13, 2017 at 3:51 PM, Christian Grothoff <address@hidden> wrote:
On 03/13/2017 09:39 PM, John Duncan wrote:
> Quick question.  I noticed when I built the library, it didn't move
> mhd_sockets.h into the includes.  That file contains all the
> MHD_send_/MHD_recv_ macros used in the websockets unit test.  Am I supposed
> to re-implement the functions/macros found in there, or am I supposed to
> include that code with my project?  I know I could just snip out the code
> and use it, but for forward compatibility I'd like to know, from the devs,
> how I should proceed for the least number of future-headaches.

Those are just convenience wrappers for us around send()/recv(). You are
not expected to use those at all in your own code. The upgrade method
gives you a socket and applications can expect to be able to use the
usual system calls (read/write/send/recv, etc.) directly with the
(web)socket.

Just be aware that you might have been given a socketpair() in case
there's actually HTTPS underneath.  Thus, stuff like ioctl() and
setsockopt() may not work correctly.  If anyone needs support there,
this would have to be added to MHD: This is what MHD_upgrade_action() is
supposed to be used for in the future, in addition to the current
close()-logic.

Happy hacking!

Christian



reply via email to

[Prev in Thread] Current Thread [Next in Thread]