From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 8C2DB8027D for ; Fri, 13 Oct 2017 23:37:43 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=rich@annexia.org; spf=Pass smtp.mailfrom=rich@annexia.org; spf=Pass smtp.helo=postmaster@annexia.org Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of rich@annexia.org) identity=pra; client-ip=80.68.91.176; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="rich@annexia.org"; x-sender="rich@annexia.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of rich@annexia.org designates 80.68.91.176 as permitted sender) identity=mailfrom; client-ip=80.68.91.176; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="rich@annexia.org"; x-sender="rich@annexia.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of postmaster@annexia.org designates 80.68.91.176 as permitted sender) identity=helo; client-ip=80.68.91.176; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="rich@annexia.org"; x-sender="postmaster@annexia.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" IronPort-PHdr: =?us-ascii?q?9a23=3A5RwQChYzIxlN5cNlKXotCkn/LSx+4OfEezUN459i?= =?us-ascii?q?sYplN5qZpc27bnLW6fgltlLVR4KTs6sC0LWG9f24EUU7or+/81k6OKRWUBEEjc?= =?us-ascii?q?hE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i76xXcoFx7+LQt4?= =?us-ascii?q?IPjuUs6X1pzvlrP6x5qGRwxVnje7fftOLJSooAPWq9le1Y9rN7w8zAePvntFZe?= =?us-ascii?q?lQwn54DVOVhRf1oMmqqs1N6SNV7rgb9sVAWL/2N5t+aPoQLjMgPnt/rJnxtBLD?= =?us-ascii?q?ZQKJ4HYMU2xQlQBHVVuWpCrmV4v853Op/tF23zOXaIivFeg5?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AlAgCnMeFZ/7BbRFBcGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBFAEBAQEBAQEBAQEBBwEBAQEBgzSBUp1zPwEBAQEBAQaBK5hDCoU7AoR?= =?us-ascii?q?WQxQBAQEBAQEBAQEBAWoogjgFAR4BBYI8AQUyAUYQCxgJExIPLRsGiiMRrj6LM?= =?us-ascii?q?gELJoMtggeBCT6BdIMqilkgBaFGApRcgiGJdIcKlW+BOTYhgVmBBwhJgmWEXz+?= =?us-ascii?q?JL4FVAQEB?= X-IPAS-Result: =?us-ascii?q?A0AlAgCnMeFZ/7BbRFBcGgEBAQECAQEBAQgBAQEBFAEBAQE?= =?us-ascii?q?BAQEBAQEBBwEBAQEBgzSBUp1zPwEBAQEBAQaBK5hDCoU7AoRWQxQBAQEBAQEBA?= =?us-ascii?q?QEBAWoogjgFAR4BBYI8AQUyAUYQCxgJExIPLRsGiiMRrj6LMgELJoMtggeBCT6?= =?us-ascii?q?BdIMqilkgBaFGApRcgiGJdIcKlW+BOTYhgVmBBwhJgmWEXz+JL4FVAQEB?= X-IronPort-AV: E=Sophos;i="5.43,372,1503352800"; d="scan'208";a="240946358" Received: from annexia.org ([80.68.91.176]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-GCM-SHA384; 13 Oct 2017 23:37:42 +0200 Received: from rich by annexia.org with local (Exim 4.89) (envelope-from ) id 1e37eH-0007l1-Gt; Fri, 13 Oct 2017 22:37:41 +0100 Date: Fri, 13 Oct 2017 22:37:41 +0100 From: "Richard W.M. Jones" To: Laurent =?iso-8859-1?Q?Th=E9venoux?= Cc: caml-list@inria.fr Message-ID: <20171013213741.ke5ptnxrq2w3n6oq@annexia.org> References: <3380AF33-0E0F-46E9-BF03-E61B65E6B838@inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3380AF33-0E0F-46E9-BF03-E61B65E6B838@inria.fr> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [Caml-list] Interfacing C with OCaml and file descriptors On Fri, Oct 13, 2017 at 12:57:33PM +0200, Laurent Thévenoux wrote: > Hi, > > I have a naive question about file descriptors and C interface (when interfacing C with OCaml). Firstly, you're confused about the difference between 'FILE *' and a file descriptor. They are not the same thing at all. Read some basic Unix texts about the difference. Once you've sorted that out, it turns out that you can (currently) cast a Unix.file_descr from OCaml directly into a C int file descriptor using Int_val: int fd = Int_val (fdv); read (fd, buf, len); It would be really nice if there was an official C function defined by OCaml to do this in a portable and future-proof way! Rich.