OK, some further digging into my problem with ocaml-ssl eventually revealed
that the problem is the way it handles Unix.file_descr. On Unix, this is
just an [int] and so ocaml-ssl's stubs treat it as such. Under Windows, it's
a custom block as file_descr is a C struct containing a lot of information.

unixsupport.h is installed with the other caml headers, although it's not
referenced by any of them and as far as I can tell isn't referred to in the
manual. For Unix implementations of OCaml, it's a pretty dull file but the
Windows version contains a definition for Socket_val which will extract the
underlying OS handle for a socket from a file_descr.

I've therefore tried inserting #include <caml/unixsupport.h> and changing
the offending portion of code in ocaml-ssl to this:

#ifdef Socket_val
  SOCKET socket = Socket_val(socket_);
#else
  int socket = Int_val(socket_);
#endif

But my questions - is this "safe"? Is it likely to continue to work? If not,
is there - or could there be - some kind of official way to extract file
descriptors which aims to work in a cross-platform manner?


David


-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to