caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] nonblocking I/O - using channels or Unix.file_descr ?
@ 2002-06-28 13:13 Basile STARYNKEVITCH
  2002-06-28 13:34 ` Xavier Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: Basile STARYNKEVITCH @ 2002-06-28 13:13 UTC (permalink / raw)
  To: caml-list

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
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

or should I do the buffering explicitly myself using only Unix.read
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.

Regards
-- 

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 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] nonblocking I/O - using channels or Unix.file_descr ?
  2002-06-28 13:13 [Caml-list] nonblocking I/O - using channels or Unix.file_descr ? Basile STARYNKEVITCH
@ 2002-06-28 13:34 ` Xavier Leroy
  0 siblings, 0 replies; 2+ messages in thread
From: Xavier Leroy @ 2002-06-28 13:34 UTC (permalink / raw)
  To: Basile STARYNKEVITCH; +Cc: caml-list

> 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-06-28 13:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-28 13:13 [Caml-list] nonblocking I/O - using channels or Unix.file_descr ? Basile STARYNKEVITCH
2002-06-28 13:34 ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).