caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jerome Vouillon <Jerome.Vouillon@pps.jussieu.fr>
To: "Jérémie Dimino" <jeremie@dimino.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Unix.connect for non-blocking sockets on Windows
Date: Wed, 10 Oct 2012 16:14:43 +0200	[thread overview]
Message-ID: <20121010141443.GA11084@pps.jussieu.fr> (raw)
In-Reply-To: <20120914173350.4867089e@arrakis>

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 <Jerome.Vouillon@pps.jussieu.fr> 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



      parent reply	other threads:[~2012-10-10 14:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-14 13:53 Romain Bardou
2012-09-14 14:27 ` Jérémie Dimino
2012-09-14 15:21   ` Jerome Vouillon
2012-09-14 15:26     ` Romain Bardou
2012-09-14 15:33     ` Jérémie Dimino
2012-09-14 15:46       ` Romain Bardou
2012-10-10 14:14       ` Jerome Vouillon [this message]

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=20121010141443.GA11084@pps.jussieu.fr \
    --to=jerome.vouillon@pps.jussieu.fr \
    --cc=caml-list@inria.fr \
    --cc=jeremie@dimino.org \
    /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).