Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Unix module API: nonblocking connect's errors retrieving
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-09-22 (14:14)
From: Markus Mottl <markus.mottl@g...>
Subject: Re: [Caml-list] Unix module API: nonblocking connect's errors retrieving
On 9/22/05, Vsevolod Fedorov <> wrote:
> The problem is: 'getsockopt_int' returns 'int' while I need Unix.error type.
> 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 Mottl