From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA21188; Fri, 28 Jun 2002 15:34:40 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA21340 for ; Fri, 28 Jun 2002 15:34:39 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g5SDYd503224; Fri, 28 Jun 2002 15:34:39 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA19496; Fri, 28 Jun 2002 15:34:38 +0200 (MET DST) Date: Fri, 28 Jun 2002 15:34:38 +0200 From: Xavier Leroy To: Basile STARYNKEVITCH Cc: caml-list@inria.fr Subject: Re: [Caml-list] nonblocking I/O - using channels or Unix.file_descr ? Message-ID: <20020628153438.A20730@pauillac.inria.fr> References: <15644.24855.239460.616880@is002254.saclay.cea.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <15644.24855.239460.616880@is002254.saclay.cea.fr>; from basile.starynkevitch@cea.fr on Fri, Jun 28, 2002 at 03:13:59PM +0200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > 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