caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Unix.file_descr and unixsupport.h
@ 2011-08-02 16:54 David Allsopp
  2011-08-02 16:58 ` Romain Beauxis
  0 siblings, 1 reply; 2+ messages in thread
From: David Allsopp @ 2011-08-02 16:54 UTC (permalink / raw)
  To: OCaml List

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-02 16:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-02 16:54 [Caml-list] Unix.file_descr and unixsupport.h David Allsopp
2011-08-02 16:58 ` Romain Beauxis

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).