Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Need advice for a mobile application server
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Basile Starynkevitch <basile.starynkevitch@i...>
Subject: Re: [Caml-list] Need advice for a mobile application server
On Thu, Nov 20, 2003 at 04:16:34PM +0000, Richard Jones wrote:
> On Thu, Nov 20, 2003 at 01:49:50PM +0100, Basile Starynkevitch wrote:
Basile>> Regarding multi-threading in Ocaml, I think that it is much less
Basile>> useful in Ocaml than say in Java or C. In my experience (on my
Basile>> previous job) I started to code a multi-threaded application (the
Basile>> POESIA monitor), and prefered to switch to a single-threaded design,
Basile>> taking into advantage the functional abilities of Ocaml (i.e. mentally
Basile>> replacing threads by sets of small correlated tasks, each represented
Basile>> as functional values, ie closures, which means coding in a
Basile>> continuation passing style).

Richard> It's interesting that you use this technique. If I get what you mean
Richard> then you're talking about a Reactor pattern (correct me if I've missed
Richard> the point).

Very probably yes, but I am not sure to exactly know what the Reactor
pattern is, even if I probably guess it.

Richard> How do you find handling state in such a model? I once tried to write
Richard> a simple HTTP server using an event-driven model, but it became a real
Richard> pain handling partial state, such as when you have only received part
Richard> of the HTTP headers.  Nevertheless this is how some webservers are
Richard> actually written, notably Boa.

And also the squid HTTP proxy (coded in C, so understanding it is not
straightforward - I believe it could be much easier to recode it in
Ocaml, using the same algorithms, and coding with lots of small
closures representing the intermediate state handling)

In the Poesia ICAP server part (the poesia monitor is an ICAP server
and an HTTP client), the partial state is explicitly kept as such.
Parsing the ICAP protocol (syntactically similar to HTTP - see or RFC3507) is done by expliciting partial states. See & source files in Poesia monitor

Richard> Also, I'm writing a server program myself in OCaml, and it uses an
Richard> event-driven model. Do you know of any freeware code for OCaml which
Richard> implements the Reactor pattern?

The Poesia monitor is open-source (or free) software, under GPL
license (see and for more). its CVS repository is
under sourceforge. The monitor is under
It uses only open-source Ocaml libraries. The HTTP client is the
Http_client module from Netclient (version >= 0.90) library. The
reactor is (as I understand it) in the Unixqueue module from the
Equeue library (version >= 1.2.3). The Ocamlnet (version >= 0.95)
library is also used.  See the README file and script
from PoesiaMonIcap

So if opensource software is freeware code for you (for me it is not;
opensource != freeware, and actually opensource > freeware) then you
can find lot of opensource ocaml code illustrating these
tricks. However, in a more usual but restrictive sense of freeware
code, I don't know of any Ocaml freeware code actually. But I
definitely don't want to start any offtopic flame war about such
terminological and philosophical issues on the Caml list, so if you
want to discuss these issues with me please reply in private.

In my previous job at CEA, I initiated Poesia which is partly funded
by the European Commission, and I believe that its opensource
character was the major reason (in additional to technical
innovations) it got funded.

FWIW, I do continue to work (mostly bug fixes) on Poesia on my spare
time at home. Of course this is unrelated to my current work at INRIA.

Basile STARYNKEVITCH -- basile dot starynkevitch at inria dot fr
Project - phone +33 1 3963 5197 - mobile 6 8501 2359 --- all opinions are only mine 

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: