caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jerome Vouillon <Jerome.Vouillon@pps.jussieu.fr>
To: Vsevolod Fedorov <sevaAtWork@mail.ru>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Unix module API: nonblocking connect's errors retrieving
Date: Tue, 27 Sep 2005 18:02:16 +0200	[thread overview]
Message-ID: <20050927160216.GA12864@strontium.pps.jussieu.fr> (raw)
In-Reply-To: <00de01c5bf7c$b9113610$670aa8c0@seva>

Hello,

On Thu, Sep 22, 2005 at 05:51:25PM +0400, Vsevolod Fedorov wrote:
> I have the following problem when using Unix module:
>
> I issuing 'connect' for nonblocked-mode socket.
> This can raise EINPROGRESS error meaning connect is not yet
> complete.  Then (as I taught by manuals) I use 'select' method and
> then 'getsockopt_int sock SO_ERROR' to retreive connect results.
> The problem is: 'getsockopt_int' returns 'int' while I need
> Unix.error type.  I can't map int to error in good way.
>
> Of couse, I can use some workarounds (and I had to use one), but
> they all are not look good.

I'm using the following piece of code as a work-around:

    begin try
      (* This succeeds only if the socket is connected *)
      ignore (Unix.getpeername fd)
    with Unix.Unix_error (Unix.ENOTCONN, _, _) ->
      (* This returns the right error message *)
      ignore (Unix.read fd " " 0 1))
    end

-- Jerome


      parent reply	other threads:[~2005-09-27 16:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-22 13:51 Vsevolod Fedorov
2005-09-22 14:14 ` [Caml-list] " Markus Mottl
2005-09-27 16:02 ` 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=20050927160216.GA12864@strontium.pps.jussieu.fr \
    --to=jerome.vouillon@pps.jussieu.fr \
    --cc=caml-list@inria.fr \
    --cc=sevaAtWork@mail.ru \
    /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).