From: Jerome Vouillon <Jerome.Vouillon@pps.jussieu.fr>
To: Romain Bardou <romain.bardou@inria.fr>
Cc: caml-list@inria.fr, "Jérémie Dimino" <jeremie@dimino.org>
Subject: Re: [Caml-list] Unix.connect for non-blocking sockets on Windows
Date: Fri, 14 Sep 2012 17:21:25 +0200 [thread overview]
Message-ID: <20120914152125.GA18300@pps.jussieu.fr> (raw)
In-Reply-To: <20120914162717.0527b04b@arrakis>
Hi Jérémie,
On Fri, Sep 14, 2012 at 04:27:17PM +0200, Jérémie Dimino wrote:
> Le Fri, 14 Sep 2012 15:53:24 +0200,
> Romain Bardou <romain.bardou@inria.fr> a écrit :
>
> > open Unix
> > let address = "xxx.xxx.xxx.xxx" in (* some IP for IPv4 *)
> > let port = 9543 in
> > let fd = socket PF_INET SOCK_STREAM 0 in
> > set_nonblock fd;
> > connect fd (ADDR_INET (Unix.inet_addr_of_string address, port))
>
> If the socket is in non-blocking mode and connect blocks, then you get
> a Unix.EWOULDBLOCK error. According to the MSDN documentation, if
> connect fails with EWOULDBLOCK, you have to wait for the socket to
> become writeable then call connect again which will fail with EISCONN
> if the connection succeeded.
This is not quite what I can read in the MSDN documentation...
"[...] it is not recommended that applications use multiple calls to
connect to detect connection completion. If they do, they must be
prepared to handle WSAEINVAL and WSAEWOULDBLOCK error values the
same way that they handle WSAEALREADY, to assure robust operation"
You should use Unix.getsockopt_error (just like under Unix) to check
for errors when the socket becomes writable, rather than call connect
again.
-- Jérôme
next prev parent reply other threads:[~2012-09-14 15:21 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 [this message]
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
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=20120914152125.GA18300@pps.jussieu.fr \
--to=jerome.vouillon@pps.jussieu.fr \
--cc=caml-list@inria.fr \
--cc=jeremie@dimino.org \
--cc=romain.bardou@inria.fr \
/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