From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p72GsbMB019703 for ; Tue, 2 Aug 2011 18:54:39 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkkCAHgrOE5RZ90vkWdsb2JhbABCp2UUAQEBAQkLCwcUAyKBRwgCHhJMBWgjDQEOAQQeBYden3agHYZCBJsuiDI X-IronPort-AV: E=Sophos;i="4.67,307,1309730400"; d="scan'208";a="104533578" Received: from mtaout01-winn.ispmail.ntl.com ([81.103.221.47]) by mail4-smtp-sop.national.inria.fr with ESMTP; 02 Aug 2011 18:54:38 +0200 Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20110802165434.HZLP2720.mtaout01-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com> for ; Tue, 2 Aug 2011 17:54:34 +0100 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout03-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20110802165434.TBJA24017.aamtaout03-winn.ispmail.ntl.com@romulus.metastack.com> for ; Tue, 2 Aug 2011 17:54:34 +0100 Received: from DIVA ([172.16.0.7]) (authenticated bits=0) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id p72GsUV9024672 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Tue, 2 Aug 2011 17:54:31 +0100 From: "David Allsopp" To: "OCaml List" Date: Tue, 2 Aug 2011 17:54:30 +0100 Organization: MetaStack Solutions Ltd. Message-ID: <000001cc5134$d990da80$8cb28f80$@metastack.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AcxRNG1IAa08ArKFS2K62rsT0pvROA== Content-Language: en-us x-ms-exchange-organization-originalclientipaddress: 172.16.0.7 x-ms-exchange-organization-originalserveripaddress: fe80::547c:3c42:e1da:eda2%10 X-Scanned-By: MIMEDefang 2.65 on 81.102.132.77 X-Cloudmark-Analysis: v=1.1 cv=R50lirqlHffDPPkwUlkuVa99MrvKdVWo//yz83qex8g= c=1 sm=0 a=ElkLV9LrsagA:10 a=cTs9vV391PwA:10 a=V35hxywFhi8A:10 a=kj9zAlcOel0A:10 a=9wwBpGz2Nb8lXGFaUjQA:9 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Subject: [Caml-list] Unix.file_descr and unixsupport.h 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 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