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.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 0BB0BBC0A for ; Wed, 10 Jan 2007 18:08:59 +0100 (CET) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.187]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0AH8w8Z025072 for ; Wed, 10 Jan 2007 18:08:58 +0100 Received: by nf-out-0910.google.com with SMTP id m19so550241nfc for ; Wed, 10 Jan 2007 09:08:58 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=qntdUI1LpOEBT6uwqMX5/on3AqVyGc8B/NRGTut69fgUeb5+A+15HH/5bBBIHYbiERaCA6oUOK0PCfyXPeMmzNqDJs8Pn81WQZpYKOFVbwBja5QFZEGTMJS6n3qQQrN/Hlm0adXuWmNqIqddJM0+zWqXw0YS0o/r5OpSx7U+ASk= Received: by 10.82.184.2 with SMTP id h2mr112316buf.1168448938257; Wed, 10 Jan 2007 09:08:58 -0800 (PST) Received: by 10.82.152.3 with HTTP; Wed, 10 Jan 2007 09:08:57 -0800 (PST) Message-ID: <9d3ec8300701100908m40f986dmafd9c41cb9fe06ba@mail.gmail.com> Date: Wed, 10 Jan 2007 18:08:57 +0100 From: "Till Varoquaux" To: "ocaml ml" Subject: Implementing rollback channels with Ocamlnet MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-j-chkmail-Score: MSGID : 45A51DAA.000 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 45A51DAA.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocamlnet:01 buffered:01 netstream:01 netchannels:01 val:01 mutable:01 val:01 mutable:01 netbuffer:01 blit:01 netchannels:01 rec:01 rec:01 exception:01 len:02 I need to be able to backtrack while reading a stream. The way I tried to do it was to build a new in_channel reading from the window of the previous (buffered) channel. Here's my current failed attempt: open Netstream;; exception BaseChannelAccess class rollback_chan (is:in_obj_stream) : Netchannels.rec_in_channel= object val mutable p_in=is#pos_in val mutable closed=false method close_in () = () method input dest dest_pos len = if (is#pos_in != p_in) then raise BaseChannelAccess; is#want(p_in+len); Netbuffer.blit is#window p_in dest dest_pos len; p_in <- p_in + len; len end;; let rollback_chan input= Netchannels.lift_in(`Rec (new rollback_chan(input))) It doesn't work (at all). I must be getting something awfully wrong, has anyone had more chance trying something similar? Till