Re: generic socket operations and SSL
Gerd Stolpmann <[email protected]> Fri, 20 Nov 2009 15:36:06 +0100
| Newsgroups | gmane.comp.lang.ocaml.lib.net.devel |
|---|---|
| Message-ID | <[email protected]> |
Am Donnerstag, den 19.11.2009, 17:15 -0800 schrieb Jake Donham: > Hi list, > > I read with interest Gerd's blog post about supporting Ocamlnet on Windows: > > http://blog.camlcity.org/blog/ocamlnet3_win32.html > > and in particular the description of generic read / write operations > on proxy file descriptors. > > I wonder: does this open the possibility of supporting SSL sockets as > another fd_style? Then e.g. Nethttpd_kernel could be made SSL-capable. It's not that easy, unfortunately. Imagine we call Ssl.read in Netsys.gread and Ssl.write in Netsys.gwrite for SSL sockets. This simple scheme works only for blocking I/O. For non-blocking I/O (as required for nethttpd), the problem is that a user-level read or write can imply a sequence of several read and writes on the socket level (e.g. for key renegotiations), but e.g. in Netsys.gread we can only assume that we can do reads on the socket level. There is no way to indicate to the caller that Netsys.gread needs to be called when the socket is writable. For the Win32 port, similar issues could be solved by introducing a user-level buffer. This is not possible for POSIX, because for Win32 a file descriptor is a heap-allocated block, which allowed to use a number of tricks to hide this buffer. 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 confess that I am a little bit confused by the Nethttpd_kernel in > the 3.0test1 release, since it uses the generic Netsys calls for some > things (e.g. in the lingering_close class) but Unix calls for others. > So it does not seem like it is ready to be used generically; although > perhaps this is not a design goal. I don't really have an explanation - there were several edit sessions where I just greped for Unix calls and replaced them by Netsys calls without thinking too much. Gerd -- ------------------------------------------------------------ Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany [email protected] http://www.gerd-stolpmann.de Phone: +49-6151-153855 Fax: +49-6151-997714 ------------------------------------------------------------ ------------------------------------------------------------------------------ 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