From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA15024; Fri, 21 Nov 2003 09:48:26 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA15137 for ; Fri, 21 Nov 2003 09:48:25 +0100 (MET) Received: from bourg.inria.fr (bourg.inria.fr [128.93.11.100]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hAL8mO129784 for ; Fri, 21 Nov 2003 09:48:24 +0100 (MET) Received: from starynke by bourg.inria.fr with local (Exim 4.24) id 1AN6xk-0003Yq-DT; Fri, 21 Nov 2003 09:48:24 +0100 Date: Fri, 21 Nov 2003 09:48:24 +0100 To: Richard Jones Cc: caml-list@inria.fr Subject: Re: [Caml-list] Need advice for a mobile application server Message-ID: <20031121084824.GA13555@bourg.inria.fr> References: <200311192003.37039.exa@kablonet.com.tr> <20031120091315.GA23449@redhat.com> <20031120102727.A28533@pauillac.inria.fr> <200311201408.06069.exa@kablonet.com.tr> <20031120124949.GA8495@bourg.inria.fr> <20031120161634.GA26689@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031120161634.GA26689@redhat.com> User-Agent: Mutt/1.5.4i From: Basile Starynkevitch X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 basile:01 basile:01 poesia:01 threads:01 closures:01 passing:01 model:01 event-driven:01 model:01 boa:99 closures:01 poesia:01 event-driven:01 open-source:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 www.i-cap.org or RFC3507) is done by expliciting partial states. See icap.ml & icapsrc.ml 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 http://www.gnu.org/philosophy/free-sw.html and http://www.gnu.org/copyleft/gpl.html for more). its CVS repository is under sourceforge. The monitor is under http://cvs.sourceforge.net/viewcvs.py/poesia/PoesiaSoft/PoesiaMonIcap/ 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 Configure.sh 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 cristal.inria.fr - phone +33 1 3963 5197 - mobile 6 8501 2359 http://cristal.inria.fr/~starynke --- all opinions are only mine ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners