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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 548C37EDD9 for ; Wed, 10 Oct 2012 16:15:13 +0200 (CEST) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of Jerome.Vouillon@pps.jussieu.fr) identity=pra; client-ip=134.157.0.129; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="Jerome.Vouillon@pps.jussieu.fr"; x-sender="Jerome.Vouillon@pps.jussieu.fr"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of Jerome.Vouillon@pps.jussieu.fr) identity=mailfrom; client-ip=134.157.0.129; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="Jerome.Vouillon@pps.jussieu.fr"; x-sender="Jerome.Vouillon@pps.jussieu.fr"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@shiva.jussieu.fr) identity=helo; client-ip=134.157.0.129; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="Jerome.Vouillon@pps.jussieu.fr"; x-sender="postmaster@shiva.jussieu.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkoBANuBdVCGnQCBkWdsb2JhbAAqGotms0gjAQEBAQkLCwcUAySCIAEBBQwmASAmEAsYLhQ1ARMTiAQLLLdai0eFQGADlWuBFpIK X-IronPort-AV: E=Sophos;i="4.80,564,1344204000"; d="scan'208";a="176658391" Received: from shiva.jussieu.fr ([134.157.0.129]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 10 Oct 2012 16:15:13 +0200 Received: from hydrogene.pps.jussieu.fr (hydrogene.pps.jussieu.fr [134.157.168.1]) by shiva.jussieu.fr (8.14.4/jtpda-5.4) with ESMTP id q9AEEjNE028277 ; Wed, 10 Oct 2012 16:14:58 +0200 (CEST) X-Ids:165 Received: from strontium.pps.jussieu.fr (strontium.pps.jussieu.fr [134.157.168.38]) by hydrogene.pps.jussieu.fr (Postfix) with ESMTPS id 9C82FC0D99; Wed, 10 Oct 2012 16:14:44 +0200 (CEST) Received: from vouillon by strontium.pps.jussieu.fr with local (Exim 4.77) (envelope-from ) id 1TLx3b-0002xK-Sx; Wed, 10 Oct 2012 16:14:44 +0200 Date: Wed, 10 Oct 2012 16:14:43 +0200 From: Jerome Vouillon To: =?iso-8859-1?Q?J=E9r=E9mie?= Dimino Cc: caml-list@inria.fr Message-ID: <20121010141443.GA11084@pps.jussieu.fr> References: <505336D4.7010700@inria.fr> <20120914162717.0527b04b@arrakis> <20120914152125.GA18300@pps.jussieu.fr> <20120914173350.4867089e@arrakis> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20120914173350.4867089e@arrakis> User-Agent: Mutt/1.5.21 (2010-09-15) X-Miltered: at jchkmail.jussieu.fr with ID 507582D5.004 by Joe's j-chkmail (http : // j-chkmail dot ensmp dot fr)! X-j-chkmail-Enveloppe: 507582D5.004/134.157.168.1/hydrogene.pps.jussieu.fr/hydrogene.pps.jussieu.fr/ X-Validation-by: jerome.vouillon@pps.jussieu.fr Subject: Re: [Caml-list] Unix.connect for non-blocking sockets on Windows On Fri, Sep 14, 2012 at 05:33:50PM +0200, Jérémie Dimino wrote: > Le Fri, 14 Sep 2012 17:21:25 +0200, > Jerome Vouillon a écrit : > > > You should use Unix.getsockopt_error (just like under Unix) to check > > for errors when the socket becomes writable, rather than call connect > > again. > > Actually, last time i tried (on Windows XP) it was not working, > Unix.getsockopt_error was returning None but the socket was not > connected. I believe that this is due to a bug in the implementation of Unix.select ( http://caml.inria.fr/mantis/view.php?id=5783 ). As a result, this function returns immediately and wrongly reports that the socket is writable. (Since OCaml 4, this bug only occurs when simultaneously selecting a non-socket file descriptor.) Thus, calling Unix.connect again instead of Unix.getsockopt_error is just a workaround for this bug: you are busy waiting for the connection to complete. (And, by the way, the secont call to Unix.connect will fail with the error code EALREADY rather that EWOULDBLOCK with Windows 8.) -- Jerome