[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] asynchronous or simultanous web service using evhttp.h
Just use an event loop and http callbacks in your server code. That's
what the whole point of libevent is, i think. I can show you an
example libevent based http page http://mappinghell.net:28888 it
refreshes some data each 2 seconds in the web page using ajax. You'll
need to manually set some http headers to make it correct, and take
advantage of the browser cache and other http features.
On Fri, Nov 12, 2010 at 12:48 AM, Basile Starynkevitch
<basile@xxxxxxxxxxxxxxxxx> wrote:
> Hello
>
> (I'm using the usual libevent 1.4 package on Debian/Sid/AMD64, but
> could compile & use libevent 2.0 if asked)
>
> I am developping a multi-threaded application using libevent -
> currently an experiment [the goal would be to develop a high-level
> programming language which is wiki-like and used thru a browser, not a
> plain textual language edited thru emacs] which I will publish as GPL
> code if & when successful. Only one thread (the main one) is running
> the libevent loop and is doing libevent calls. All other threads are
> not doing anything libevent related. Some event callbacks (running in
> the main loop) are using bounded timed pthread calls, in particular
> pthread_cond_timedwait. Some non-main threads are also occasionnally
> (and atomically) writing into a pipe which is read by libevent
> callbacks.
>
> Is there a possibility to use evhttp.h functions asynchronously, in
> particular to handle several (eg. 2-4) HTTP requests at once (typically
> I was thinking of AJAX, e.g. a browser tab doing some XMLHttpRequest
> while another tab is actively used by the user who is e.g. POST-ing
> from an XHTML form; so the application would need to reply to the
> XMLHttpRequest while it is replying to the user in another browser
> tab.), ? How can I achieve that? By creating a thread for each request?
> By waiting for several HTTP requests in libevent? How?
>
> This is an experiment, and performance does not matter much. However, I
> really want my application to run several threads... so making it
> monothreaded is not possible!!
>
> Example code are welcome.
>
> If you want me to put my (alpha-stage, 3000+ lines of C) code on some
> web server, I could do that, but it does not show much!
>
> cheers
> --
> Basile STARYNKEVITCH Â Â Â Â http://starynkevitch.net/Basile/
> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> *** opinions {are only mine, sont seulement les miennes} ***
> ***********************************************************************
> To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
> unsubscribe libevent-users  Âin the body.
>
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.