Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gerd Stolpmann <info@g...>
Subject: Re: [Caml-list] node.ocaml
You may also look at ocamlnet
(, which provides a
stack of abstractions for event-driven programming:

- The Netsys library defines an object type for sets of file
  descriptors one can poll:

  There is right now only an implementation for poll(), but
  no fancy things like what libevent provides (but this is 
  just lack of time).

- Above that, there is the equeue library with its main
  interface Unixqueue:

  This provides a queue of events, and a mechanism to consume

- Above that, there is the engines API:

  This is an abstraction allowing easy composition of code. An
  engine represents a suspended I/O operation to which one can
  attach continuations.

There are even implementations of high-level protocols using these APIs
(most hooking in at the Unixqueue level), and this includes HTTP,
Telnet, FTP (partly), and SunRPC. Companies are using this already in
products, so this is really a mature implementation. 

It is interesting that in your code the callbacks are implemented on the
C side. I think this is generally more complicated than doing the same
in Ocaml which is way more a "callback-friendly" language.


Am Samstag, den 21.08.2010, 22:27 -0500 schrieb Jeffrey Barber:
> I've been working with libevent2 and OCaml for the past couple of
> weeks to build node.ocaml. It is far from done, but it is interesting
> enough to share.
> node.ocaml as of now contains a web server and a terminal server that
> provides asynchronous programming to OCaml to enable some of my
> research. The first example server is a key value pair server that
> brings OCaml's Hashtbl to http and terminal IO:
> example code:
> This is the first test program, and it works fairly well in a single
> threaded environment. I was inspired by node.js to build an evented io
> system, and so I begged the question "how does 'OCaml's FFI' compare
> with v8's in node.js". In my virtual machine environment (ubuntu
> 10.04), I got the following results doing 10,000 requests 50 at a
> time:
> node.js with the "Hello World" script:
> 2100 requests/second
> node.ocaml with
> 5300 requests/second
> This seems to me to be a very positive first benchmark considering I
> haven't optimized anything yet nor have I hacked caml_copy_string yet.
> The code is licensed under BSD and available
> .
> Any thoughts/questions are appreciated; thank you for your time.
> -J
> _______________________________________________
> Caml-list mailing list. Subscription management:
> Archives:
> Beginner's list:
> Bug reports:

Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany
Phone: +49-6151-153855                  Fax: +49-6151-997714