caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Joel Reymont <joelr1@gmail.com>
To: Caml List <caml-list@inria.fr>
Cc: Gerd Stolpmann <gerd@gerd-stolpmann.de>
Subject: Sample web server with nethttpd
Date: Fri, 30 Mar 2007 15:38:41 +0100	[thread overview]
Message-ID: <CA1B2BE6-55E1-47D5-8056-00D029348039@gmail.com> (raw)

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/






             reply	other threads:[~2007-03-30 14:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-30 14:38 Joel Reymont [this message]
2007-03-30 14:59 ` [Caml-list] " Gerd Stolpmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA1B2BE6-55E1-47D5-8056-00D029348039@gmail.com \
    --to=joelr1@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=gerd@gerd-stolpmann.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).