Version française
Home     About     Download     Resources     Contact us    
Browse thread
select (or polling) on in_channel?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gerd Stolpmann <gerd@g...>
Subject: Re: [Caml-list] select (or polling) on in_channel?
Am Donnerstag, den 31.03.2005, 18:28 -0500 schrieb Eijiro Sumii:
> Hi again...
> 
> Is there any easy way to _correctly_ do a "select" (as in the UNIX
> system call) on Pervasives.in_channel?  My naive approach
> 
>   Unix.select [Unix.descr_of_in_channel ic] [] [] 0.
> 
> seems to fail (and it indeed does fail) because of the buffering
> inside Pervasives.in_channel, as long as I checked the source code of
> ocaml-3.08.3.  Pervasives.in_channel_length doesn't help in my case
> since the input channel is not a file.  Should I use only the
> low-level functions in the Unix module if I _ever_ want "select"?

Yes. The point is that you cannot interpret the result of Unix.select in
a reasonable manner. When Unix.select says the descriptor has no data,
it might still the case that there are data in the buffer. If the
descriptor has data, you don't know when they are exactly read into the
buffer.

I don't understand why you mention in_channel_length here. What is your
real problem?

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
------------------------------------------------------------