libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Protocol upgrade


From: Christian Grothoff
Subject: Re: [libmicrohttpd] Protocol upgrade
Date: Sun, 13 Nov 2016 21:39:42 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0

On 11/13/2016 08:47 PM, Markus Doppelbauer wrote:
> Hello,
> 
> Is the "protocol upgrade" API finalized? 

Let's say I have no intention of changing it dramatically.

> I can live with that, but this
> way I need a second event loop. I would prefer an API where the MHD
> event loop waits for websocket-data and - if new data arrives - calls
> a handler. Something like:
> 
> MHD_SocketHandle *
> MHD_create_response_for_upgrade(
>     MHD_UpgradeDataArrivedHandler read_handler,  // when data is
> available
>     MHD_UpgradeSocketClosedHandler close_handler ); // when socket is
> closed
> void
> MHD_upgrade_write( MHD_SocketHandle *handle, void *data, size_t size );
> void
> MHD_upgrade_close( MHD_SocketHandle *handle );

This doesn't work for various reasons. You can't just "write" like that
due to flow control.  Similarly, MHD can't just read and call you like
this, as your application might not be able to handle the data rate (and
if your application blocks processing the data, that'd block MHD
processing other activities in most threading modes).  So in the
interest of keeping the API simple, giving you a socket is really the
best option IMO.

Happy hacking!

Christian

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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