From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA18576; Sat, 20 Jul 2002 16:20:57 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA18571 for caml-list@pauillac.inria.fr; Sat, 20 Jul 2002 16:20:56 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA00592 for ; Fri, 19 Jul 2002 14:53:35 +0200 (MET DST) Received: from drat.cs.umd.edu (drat.cs.umd.edu [128.8.128.23]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6JCrWv15490 for ; Fri, 19 Jul 2002 14:53:34 +0200 (MET DST) Received: from laptop (mwhlaptopvm.cs.umd.edu [172.16.0.149]) by drat.cs.umd.edu (8.11.0/8.11.0) with SMTP id g6JCrRW06655; Fri, 19 Jul 2002 08:53:28 -0400 (EDT) From: "Michael Hicks" To: "Brian Naylor" , Subject: RE: [Caml-list] serialize/deserialize Date: Fri, 19 Jul 2002 09:51:57 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 In-Reply-To: <20020719061837.10716.qmail@web13406.mail.yahoo.com> Importance: Normal Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk You can always write your own serialization functions from scratch, based on streams. In our networking implementation written in OCaml (see http://www.cis.upenn.edu/~switchware/PLAN/), we wrote a simple package for marshalling ints, strings, characters, etc. into our own version of streams. These streams could then be dumped to a string (which was fast, since our streams are represented by strings internally) and sent out as packets. We tuned it for speed and space a while back, so hopefully it's not too slow. If you download the distribution at the above URL, take a look at plan/util/marshal_prim.ml for the basic package and then look at plan/basis/marshalling.ml to see how we used the marshalling primitives for our application. Note that most of this code was written before there was a generic OCaml Buffer module, so it probably could be rewritten to use that, but I haven't looked into it. Mike -----Original Message----- From: owner-caml-list@pauillac.inria.fr [mailto:owner-caml-list@pauillac.inria.fr]On Behalf Of Brian Naylor Sent: Friday, July 19, 2002 1:19 AM To: caml-list@inria.fr Subject: [Caml-list] serialize/deserialize I need to write my own marshalling functions for a network protocol stack. Is there any way I can make use of the serialization and deserialization functions? Has anyone trod this path before me and is willing to share their wisdom? Why am I doing this, you ask? Bandwidth is critical, and custom marshalling can save a lot of space - especially in getting rid of headers. Also, I want to do things like serialize some info, add a MAC, then serialize some more. The off-the-shelf solution is too space-inefficient: let alen = Marshal.to_buffer buf ofs max adata [] in let mac = Digest.substring buf ofs alen in let blen = Marshal.to_buffer buf (ofs + alen) (max - alen) (mac, bdata) [] in ... Thanks for any advice... __________________________________________________ Do You Yahoo!? Yahoo! Autos - Get free new car price quotes http://autos.yahoo.com ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners