Re: generic socket operations and SSL

Jake Donham <[email protected]> Fri, 20 Nov 2009 12:38:49 -0800
Newsgroups gmane.comp.lang.ocaml.lib.net.devel
Message-ID <[email protected]>
On Fri, Nov 20, 2009 at 6:36 AM, Gerd Stolpmann <[email protected]> wrote:
> For enabling SSL I would rather suggest to change nethttpd_kernel so it
> uses the multiplex_controller class for I/O instead of sockets. This is
> not that difficult, and would make it fully generic. Essentially,
> multiplex_controller is a generic communication endpoint that can be
> implemented for almost any kind of I/O mechanisms (sockets, SSL sockets,
> smoke signs, ...).

I had wondered about this as well. Since Nethttpd_kernel is written in
a clever way that allows it to be used in both nonblocking and
blocking styles, I wasn't sure if it was feasible to use
multiplex_controller, since that is written as an engine (with
when_done callbacks).

It seems to me that once you depend on an asynchronous /
callback-based interface, there is no way to recover a direct-style
interface, short of running the event queue or using a separate
thread.

Would it be possible to run the event queue only until a particular
event (or one of a set of events) has occurred? (I think in the
current interface there is only a top-level run that finishes the
whole event system.) Then in Nethttpd_kernel.http_protocol#block,
instead of calling Unix.select directly, one could run the queue until
the input or output multiplex_controller is ready. It is a little bit
hard to see how the interface should look; somehow
multiplex_controller would need to expose its resources in order that
client code could wait on more than one of them.

Alternatively one might abandon the direct-style option in
Nethttpd_kernel, and have Nethttpd_reactor be merely a wrapper around
Nethttpd_engine, that calls Unixqueue.run to handle a whole
connection's worth of events.

Thank you for the reply. Best,

Jake

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july