From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 9D4BBBB81 for ; Thu, 22 Sep 2005 16:14:51 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j8MEEpp5014457 for ; Thu, 22 Sep 2005 16:14:51 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA03874 for ; Thu, 22 Sep 2005 16:14:50 +0200 (MET DST) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.204]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j8MEEafG009043 for ; Thu, 22 Sep 2005 16:14:50 +0200 Received: by xproxy.gmail.com with SMTP id s6so547306wxc for ; Thu, 22 Sep 2005 07:14:50 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=gGHcubIV1KndFl8RWW89GYYs0OQCXQ8dO+KJFBUyfTWaE3BXp0ZB7VgUr7cSJgPvSofKhsgZPClQ8skI6FZdY4cceoQ1Olu/Nkvd5UKu+gE/SrRXW7kB4gbIH8g5mY4Msijg0gveYiqdAbFGWhbKMUejshwCOcNg6qFB7vGCAio= Received: by 10.70.50.2 with SMTP id x2mr240467wxx; Thu, 22 Sep 2005 07:14:49 -0700 (PDT) Received: by 10.70.20.9 with HTTP; Thu, 22 Sep 2005 07:14:49 -0700 (PDT) Message-ID: Date: Thu, 22 Sep 2005 10:14:49 -0400 From: Markus Mottl Reply-To: Markus Mottl To: Vsevolod Fedorov Subject: Re: [Caml-list] Unix module API: nonblocking connect's errors retrieving Cc: caml-list@inria.fr In-Reply-To: <00de01c5bf7c$b9113610$670aa8c0@seva> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <00de01c5bf7c$b9113610$670aa8c0@seva> X-Miltered: at concorde with ID 4332BC5B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4332BC4C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; markus:01 mottl:01 markus:01 mottl:01 caml-list:01 api:01 int':01 'int':01 api:01 'int:01 converts:01 -function:01 ocaml:01 unix-module:01 ocaml:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=INFO_TLD,RCVD_BY_IP autolearn=disabled version=3.0.3 On 9/22/05, Vsevolod Fedorov wrote: > The problem is: 'getsockopt_int' returns 'int' while I need Unix.error ty= pe. > I can't map int to error in good way. I have also run into this same problem a while ago. > May be is it the time to extend Unix module API? > For example, add function like 'getsockopt_error' or 'int_to_error'? There is already a C-function for handling that case in the OCaml-runtime (unix_error). You only need to write a C-wrapper that converts the arguments to this function appropriately, and define an "external"-function in OCaml. Then you can raise the corresponding Unix_error-exceptions by passing the error code and other arguments (i.e. name of associated Unix-call and arguments). But I agree, it would be a very good idea to expose this function in the standard Unix-module (hint, hint!)... Best regards, Markus -- Markus Mottl http://www.ocaml.info markus.mottl@gmail.com