From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id CBB45BC84 for ; Fri, 1 Apr 2005 12:59:28 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j31AxSfe006606 for ; Fri, 1 Apr 2005 12:59:28 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA29805 for ; Fri, 1 Apr 2005 12:59:27 +0200 (MET DST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j31AxR3p006603 for ; Fri, 1 Apr 2005 12:59:27 +0200 Received: from [212.227.126.160] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1DHJs5-0007BF-00; Fri, 01 Apr 2005 12:59:25 +0200 Received: from [84.167.161.146] (helo=gate.lan.gerd-stolpmann.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1DHJs5-0002dr-00; Fri, 01 Apr 2005 12:59:25 +0200 Received: from flakew.lan.gerd-stolpmann.de (flakew [192.168.0.32]) by gate.lan.gerd-stolpmann.de (Postfix) with ESMTP id E7E6AC30F; Fri, 1 Apr 2005 12:59:24 +0200 (CEST) Subject: Re: [Caml-list] select (or polling) on in_channel? From: Gerd Stolpmann To: Eijiro Sumii Cc: caml-list@inria.fr, sumii@saul.cis.upenn.edu In-Reply-To: <20050331.182855.07449233.eijiro_sumii@anet.ne.jp> References: <20050331.182855.07449233.eijiro_sumii@anet.ne.jp> Content-Type: text/plain Date: Fri, 01 Apr 2005 12:59:24 +0200 Message-Id: <1112353164.6180.10.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:a6865a839c0178d9aa0ce41878507ea2 X-Miltered: at nez-perce with ID 424D2990.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 424D298F.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 polling:01 gerd:01 stolpmann:01 gerd:01 donnerstag:01 eijiro:01 sumii:01 pervasives:01 buffering:01 pervasives:01 low-level:01 buffer:01 buffer:01 stolpmann:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: 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 ------------------------------------------------------------