[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] Protocol upgrade
From: |
Evgeny Grin |
Subject: |
Re: [libmicrohttpd] Protocol upgrade |
Date: |
Mon, 14 Nov 2016 14:05:53 +0300 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 |
Hi Markus,
We are trying to avoid blocking of MHD by external processing of
"upgraded" socket data.
Currently these is no way to register such notification and it couldn't
be easily added for non-TLS connections.
But even if we'll add it - it will block MHD if you will process data in
the caller thread. And anyway you will need a poll()/select() to send data.
For simplicity - you can use poll() (which is available almost
everywhere) and separate thread for each upgraded socket. If you need
compatibility with older W32 versions - you can use select() for W32 as
select() on W32 doesn't have limitation on socket's number.
--
Best Wishes,
Evgeny Grin
On 14.11.2016 12:00, Markus Doppelbauer wrote:
> 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, 2016/11/14
- Re: [libmicrohttpd] Protocol upgrade,
Evgeny Grin <=
- 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