From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr 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 3BD77BC96 for ; Wed, 23 Aug 2006 07:27:45 +0200 (CEST) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.230]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k7N5Riqi007239 for ; Wed, 23 Aug 2006 07:27:44 +0200 Received: by wx-out-0506.google.com with SMTP id s6so2889wxc for ; Tue, 22 Aug 2006 22:27:44 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=lJUVnaMpVfCKyaE5cOOHP6lY/oyZK3hrwTGk+mqCxntEkRu/95BOjDFPkErcEk9D6TlJ0CfAQxYgAv1/p5giWlXaaOFaklXdd/5COV47fbT3m1LAeCgV36Vugp0WjdgL4cjgig4JKTRmbrjHgEUfiHoMpmbSQxUgHewFcgxCSYI= Received: by 10.90.54.20 with SMTP id c20mr2698aga; Tue, 22 Aug 2006 22:27:43 -0700 (PDT) Received: by 10.90.106.19 with HTTP; Tue, 22 Aug 2006 22:27:43 -0700 (PDT) Message-ID: Date: Tue, 22 Aug 2006 22:27:43 -0700 From: "Nathaniel Gray" To: "Olivier Andrieu" Subject: Re: [Caml-list] Re: Select on channels (again) Cc: "Caml Mailing List" In-Reply-To: <17642.48113.637250.34242@karryall.dnsalias.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <17642.48113.637250.34242@karryall.dnsalias.org> X-j-chkmail-Score: MSGID : 44EBE750.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44EBE750.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; andrieu:01 oandrieu:01 unix:01 unix:01 ocaml:01 descriptors:01 ocaml:01 buffer:01 buffer:01 non-blocking:01 buffered:01 buffered:01 cheers:01 2006:98 wrote:01 On 8/22/06, Olivier Andrieu wrote: > Nathaniel Gray [Monday 21 August 2006] : > > > > On 8/21/06, Jonathan Roewen wrote: > > > Why can't you just use the unix file opening functions since you're > > > using unix select? And if you need the ocaml in/out channels, convert > > > the unix file descriptors to ocaml ones instead of the other way > > > around. Seems simple enough to me. > > > > It sounds simple but doesn't work. If select tells you a file > > descriptor doesn't have data waiting you can't be sure there isn't > > still data in the corresponding channel's buffer. See the thread that > > I referenced for a good discussion of why this is annoying. For one > > thing, it makes it impossible to use Marshal.from_channel without > > potentially blocking. > > Indeed, Marshal.from_channel would block, but it's not the only way to > read a marshalled value: cf. Marshal.header_size and > Marshal.data_size. > > With these, you can read your marshalled value from file_descr into a > buffer in a non-blocking, select-compatible way and then use > Marshal.from_string. Yes, as I said, it's possible to work around this limitation by creating yet another implementation of buffered I/O. My point is that there's already a good buffered I/O implementation in ocaml that could suit many (but not all) needs -- channels. Adding channel_select would make channels a lot more useful at very little expense. Heck, I would be satisfied with in/out_channel_is_ready, which would be even easier! Cheers, -n8 -- >>>-- Nathaniel Gray -- Caltech Computer Science ------> >>>-- Mojave Project -- http://mojave.cs.caltech.edu -->