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
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: 2005-04-01 (10:59)
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.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 in
a reasonable manner. When 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

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

Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany