caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "David Allsopp" <dra-news@metastack.com>
To: "OCaml List" <caml-list@inria.fr>
Subject: [Caml-list] Unix.file_descr and unixsupport.h
Date: Tue, 2 Aug 2011 17:54:30 +0100	[thread overview]
Message-ID: <000001cc5134$d990da80$8cb28f80$@metastack.com> (raw)

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


             reply	other threads:[~2011-08-02 16:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-02 16:54 David Allsopp [this message]
2011-08-02 16:58 ` Romain Beauxis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000001cc5134$d990da80$8cb28f80$@metastack.com' \
    --to=dra-news@metastack.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).