Version française
Home     About     Download     Resources     Contact us    
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
> Unix.select 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
blocking.

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners