libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Writing response to socket?


From: Nicholas J Humfrey
Subject: Re: [libmicrohttpd] Writing response to socket?
Date: Fri, 1 Jan 2010 20:31:59 +0000

Hi Christian,

Thanks for the advice, I will give that a try.

nick.

On 1 Jan 2010, at 13:10, Christian Grothoff wrote:

> Hi!
> 
> If you are using the external select model, this should be possible.  You'll 
> need to use an internal buffer; whenever MHD polls and the buffer is empty, 
> you return 0.  Then, once librdf pushes you first copy into the buffer and 
> then next time MHD polls you give it to MHD.  If you are able to "defer" 
> pushing by librdf until your buffer is not full, you should be able to do 
> this 
> with a bounded buffer size.  Naturally, librdf would need to be integrated 
> with your main external select loop (that select would need to unblock on RDF 
> or MHD activity).
> 
> Alternatively, with "thread-per-connection", you could just block on the MHD-
> read until RDF pushes; naturally, if RDF pushes before MHD reads you'd again 
> need to buffer. So yes, I think this can be done, but may involve some non-
> trivial code.
> 
> Happy hacking!
> 
> Christian
> 
> On Thursday 31 December 2009 01:25:11 pm Nicholas J Humfrey wrote:
>> Hello,
>> 
>> I am writing an RDF Triplestore[1] called Redstore[2] using the Redland[3]
>> libraries.
>> 
>> The HTTP responses could end up being quite large, so I would like to try
>> and stream the results, rather than storing it all in memory first, as I
>> am at the moment.
>> 
>> Is there a way that I can write directly to the connection socket? I have
>> looked at the callback methods and fileserver_example.c but I can't see
>> how I can tie that into the Redland library API.
>> 
>> Here are the serializer functions available from Redland:
>> librdf_serializer_serialize_stream_to_file()
>> librdf_serializer_serialize_stream_to_file_handle()
>> librdf_serializer_serialize_stream_to_iostream()
>> librdf_serializer_serialize_stream_to_string()
>> 
>> I am currently using the 'to_string' method and then constructing the HTTP
>> response. In order to use to_file_handle or to_iostream, there seems to be
>> a bit of a control inversion problem. librdf wants to push the results to
>> a socket and libmicrohttpd wants to pull the results.
>> 
>> Any suggestions?
>> 
>> 
>> Thanks,
>> 
>> nick.
>> 
>> 
>> [1] http://en.wikipedia.org/wiki/Triplestore
>> [2] http://code.google.com/p/redstore/
>> [3] http://www.librdf.org/
>> 





reply via email to

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