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
[Caml-list] nonblocking I/O - using channels or Unix.file_descr ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Basile STARYNKEVITCH <basile.starynkevitch@c...>
Subject: [Caml-list] nonblocking I/O - using channels or Unix.file_descr ?
Dear All,

I want to code nonblocking IO on Linux (I am not concerned with
"portability" problems to non-unix system). Of course I will use to wait for availability of input and output.  (I do not
want to use multithreading here  because I might have several dozens of such
I/O "ports" thru Unix named FIFOs).

Can I use Pervasives channels and then

Unix.set_nonblock (Unix.descr_of_in_channel myinchan)
Unix.set_nonblock (Unix.descr_of_out_channel myoutchan)

and then read & write bytes with
  Pervasives.input myinchan buf pos len
  Pervasives.output myoutchan buf pos len

or should I do the buffering explicitly myself using only
and Unix.write

Apparently, the code in ocaml/byterun/io.c (notably the do_read and
do_write internal functions there) seems to be able to deal with
nonblocking channels, but I am not fully sure of this.


N.B. Any opinions expressed here are only mine, and not of my organization.
N.B. Les opinions exprimees ici me sont personnelles et n engagent pas le CEA.

Basile STARYNKEVITCH   ----  Commissariat à l Energie Atomique * France
DRT/LIST/DTSI/SLA * CEA/Saclay b.528 (p111f) * 91191 GIF/YVETTE CEDEX 
phone:+33 1,6908.6055; fax: 1,6908.8395 home: 1,4665.4553; mobile: 6,8501.2359
work email: Basile point Starynkevitch at cea point fr 
home email: Basile at Starynkevitch point net

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: