From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 77E7BBC6B for ; Fri, 30 Mar 2007 16:59:07 +0200 (CEST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2UEx6Xe020067 for ; Fri, 30 Mar 2007 16:59:07 +0200 Received: from [84.59.100.205] (helo=gate.lan.gerd-stolpmann.de) by mrelayeu.kundenserver.de (node=mrelayeu4) with ESMTP (Nemesis), id 0ML21M-1HXIZE1vhl-0000aM; Fri, 30 Mar 2007 16:59:04 +0200 Received: from flakew.lan.gerd-stolpmann.de (fw.lan.gerd-stolpmann.de [192.168.1.1]) by gate.lan.gerd-stolpmann.de (Postfix) with ESMTP id 14F10C094; Fri, 30 Mar 2007 16:59:04 +0200 (CEST) Subject: Re: [Caml-list] Sample web server with nethttpd From: Gerd Stolpmann To: Joel Reymont Cc: Caml List In-Reply-To: References: Content-Type: text/plain Date: Fri, 30 Mar 2007 16:59:02 +0200 Message-Id: <1175266743.1530.238.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX195X5/fttXpsM0PMtmD/UyKKH6985I1YV+/zLo qLxRrI+LkTOQkSoAnZdMYK2/TsTmpnpeJn2128di4qNZOx9tIy YBUTxHbKaDAwN/yfHq0P1fDTxaxITHN X-Miltered: at discorde with ID 460D25BA.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; gerd:01 stolpmann:01 ocaml:01 ocaml:01 uploading:01 event-based:01 event-based:01 gerd:01 stolpmann:01 viktoriastr:01 64293:01 darmstadt:01 6151:01 6151:01 caml-list:01 Am Freitag, den 30.03.2007, 15:38 +0100 schrieb Joel Reymont: > I'm trying to bring up a web app as soon as possible and failing to > link Ruby with OCaml code my choice is to decouple and put an app > server behind Rails. Apache is heavy-weight so mod_caml is out of the > question. The choice is nethttpd and Ocsigen. > > My OCaml app server needs to take a POST request, grab the posted > source code, translate it and spit it out. I can't figure out how to > bring up a web server with nethttpd, though. > > It would be extremely helpful to have an expanded nethttpd tutorial > [1] that included a sample web server. I read through but writing > efficient code to accept connections in OCaml seems daunting and the > choice between engine and reactor unclear. > > There's a sample web server in the Netplex intro, though[2], is that > sufficient? Maybe the nethttpd intro should just point to the Netplex > one. Yes, the Netplex one is fully sufficient, and this is the way to go except you have very specific needs. The Nethttpd modules more or less provide a construction kit for web servers. Using them require a basic understanding how servers are constructed in general. Sorry that I cannot give a recipe. > Quoting the manual: > >>> Second, select an encapsulation. > > How is this done, precisely? Use either the reactor module or the engine module. > >>> As mentioned, the reactor is much simpler to use, but you must > take a multi-threaded approach to serve multiple connections > simultaneously. > > What's the standard (optimal) pattern here? Are there any code samples? You seem to be blind. There are examples. > >> The engine is more efficient, but may use more memory (unless it > is only used for static pages). > > How much more memory? Is there a rule of thumb? The engine needs memory buffers to store the incoming request. Depends on the size of the requests. If you are not uploading files, you can ignore that. > How should I decide whether to pick an engine or a reactor? Depends on what you can master. The engine is more difficult, you need knowledge about event-based programming. If you don't have that knowledge, keep away from it. > >>> Third, write the code to create the socket and to accept > connections. > > Should I use the netplex intro sample code? Don't know how to answer this. I cannot decide for you. > >>> For the reactor, you should do this in a multi-threaded way (but > multi-processing is also possible). For the engine, you should do > this in an event-based way. > > It appears that web servers like Lighttpd use the event-based way, > should I pick that? You find both approaches. Apache is multi-{processed,threaded}. This mainly depends what you are also doing in your application. Gerd -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de Phone: +49-6151-153855 Fax: +49-6151-997714 ------------------------------------------------------------