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: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] nonblocking I/O - using channels or Unix.file_descr ?
> 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

Yes -- the bytecode thread library does just that.
Be prepared to handle the Sys_blocked_io exception that will be raised
by Pervasives I/O functions when they cannot complete without

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