libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Query on async response using microhttpd


From: Andreas Wehrmann
Subject: Re: [libmicrohttpd] Query on async response using microhttpd
Date: Mon, 1 Aug 2016 07:06:44 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 07/29/2016 07:28 PM, Geetha Shanmugam wrote:
Hi,

We are trying to use libmircohttpd in the following scenario.



Process P1 start MHD daemon in the external select mode.

It has to communicate to another process say P2 to send out the response.

The communication between P1 and P2 are via sockets (already tested and
working model)

P1 should be able to receive and process multiple request without blocking.

The response should be sent asynchronously, not from the access handler
callback function.



Is there an example that I can refer to understand how this can be done?



 From reading thru the archive and manual, i understand that we can use the
following APIs

1. MHD_suspend connection() can be called from access handler callback
function, so the daemon can process the other incoming request, when the
first one is being processed.

2. MHD_resume_connection() to send out the response once it is ready.

3. MHD_create_response_from_callback() - with a content reader callback and
content reader free callback.

But unable to get the complete flow as how this can be done.



Thanks,

Geetha


I build something exactly like that (except I'm not using external select).
I've got a single-threaded server that receives requests and depending on the URI
forwards the requests to other processes via abstract UDOM sockets
then waits for a response and returns it to the client.

The flow is quite easy:

1. In the AccessHandler callback, forward your request to the other process, then call suspend_connection() 2. When you receive a response (or run into a timeout waiting for the process to respond, depending on how you communicate exactly...) you buffer the response in some handle related to the connection you're responding to and then you call resume_connection() 3. Your AccessHandler callback is called again soon afterwards where you can now return your buffered response to the client.

Hope this helps.







reply via email to

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