[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] Protocol upgrade
From: |
Markus Doppelbauer |
Subject: |
Re: [libmicrohttpd] Protocol upgrade |
Date: |
Mon, 14 Nov 2016 10:00:27 +0100 |
Hello,
Writing directly to the socket does not bother me. My problem
is: In order to use websockets we need a second
"select/poll/epoll" event loop (which is not that easy if you
don't want to pull in 'libev').
Would it be possible to register the socket to the MHD event
loop? So that MHD could tell me if data arrives?
Thanks a lot!
Markus
Am Sonntag, den 13.11.2016, 21:39 +0100 schrieb 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
- [libmicrohttpd] Protocol upgrade, Markus Doppelbauer, 2016/11/13
- Re: [libmicrohttpd] Protocol upgrade, Christian Grothoff, 2016/11/13
- Re: [libmicrohttpd] Protocol upgrade,
Markus Doppelbauer <=
- Re: [libmicrohttpd] Protocol upgrade, Evgeny Grin, 2016/11/14
- Re: [libmicrohttpd] Protocol upgrade, Markus Doppelbauer, 2016/11/14
- Re: [libmicrohttpd] Protocol upgrade, Evgeny Grin, 2016/11/14
- Re: [libmicrohttpd] Protocol upgrade, Markus Doppelbauer, 2016/11/14
- Re: [libmicrohttpd] Protocol upgrade, Evgeny Grin, 2016/11/14
- Re: [libmicrohttpd] Protocol upgrade, Christian Grothoff, 2016/11/14
- Re: [libmicrohttpd] Protocol upgrade, Markus Doppelbauer, 2016/11/14
- Re: [libmicrohttpd] Protocol upgrade, Junker, Gregory, 2016/11/14