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=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 2C143BC69 for ; Fri, 30 Mar 2007 16:38:47 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.168]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2UEYiAa011237 for ; Fri, 30 Mar 2007 16:38:46 +0200 Received: by ug-out-1314.google.com with SMTP id k3so904641ugf for ; Fri, 30 Mar 2007 07:38:46 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=hyTS6kQuctMMBsjQNOsAisRALD7SpCpg+7aJ+psytjzg0/Vf+dtyUAmqmzarB+V5jecEzYOLolu/6968aUBhaHLrp4zpV2kioo2pQAFsF/tZ9qtEScfj6uTA/ONETTfw7Fx4pBl+oZnq8RmlA9TkvIOIopA9iPydzig3kbKbQOc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=o39alSWE7Q4+G081jHpE6jJVCuH90yGfqYM1w7oBPkMiHrbdBSP1f2bxZNCCE4FGHaHWzbVZP6mX5bg86nfEodf7nnJQuQHM2EA9MRS5CvCf8Ot4g6GR2WZUhnNFLVCYOnuLPVd3Zvzobci/2MUEeO4JEBkrtuKTnZn68Gf4QmU= Received: by 10.67.96.14 with SMTP id y14mr2266124ugl.1175265525614; Fri, 30 Mar 2007 07:38:45 -0700 (PDT) Received: from ?192.168.1.34? ( [88.7.143.102]) by mx.google.com with ESMTP id q40sm3338980ugc.2007.03.30.07.38.43; Fri, 30 Mar 2007 07:38:44 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: Gerd Stolpmann Content-Transfer-Encoding: 7bit From: Joel Reymont Subject: Sample web server with nethttpd Date: Fri, 30 Mar 2007 15:38:41 +0100 To: Caml List X-Mailer: Apple Mail (2.752.3) X-j-chkmail-Score: MSGID : 460D2005.000 on concorde : j-chkmail score : XXXX : 5/20 2 0.000 -> 4 X-Miltered: at concorde with ID 460D2005.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 event-based:01 event-based:01 ocamlnet:01 ocamlnet:01 sourceforge:01 sourceforge:01 precisely:01 caml:02 quoting:02 failing:02 seems:03 static:03 tutorial:04 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. Quoting the manual: >>> Second, select an encapsulation. How is this done, precisely? >>> 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? >> 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? How should I decide whether to pick an engine or a reactor? >>> Third, write the code to create the socket and to accept connections. Should I use the netplex intro sample code? >>> 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? Thanks, Joel [1] http://ocamlnet.sourceforge.net/manual-2.2/Nethttpd_intro.html [2] http://ocamlnet.sourceforge.net/manual-2.2/Netplex_intro.html -- http://wagerlabs.com/