[libmicrohttpd] Protocol upgrade

2016-11-13 Thread Markus Doppelbauer
Hello,

Is the "protocol upgrade" API finalized? 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 );

Thanks a lot!
Markus

Re: [libmicrohttpd] Protocol upgrade

2016-11-13 Thread Christian Grothoff
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



signature.asc
Description: OpenPGP digital signature