caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Michael Hicks" <mwh@cs.umd.edu>
To: "Brian Naylor" <bwv211mail@yahoo.com>, <caml-list@inria.fr>
Subject: RE: [Caml-list] serialize/deserialize
Date: Fri, 19 Jul 2002 09:51:57 -0500	[thread overview]
Message-ID: <MCEJKGLFOBBOHDNADBNAIECMCAAA.mwh@cs.umd.edu> (raw)
In-Reply-To: <20020719061837.10716.qmail@web13406.mail.yahoo.com>

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 <caml/intext.h> 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


      reply	other threads:[~2002-07-20 14:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-19  6:18 Brian Naylor
2002-07-19 14:51 ` Michael Hicks [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MCEJKGLFOBBOHDNADBNAIECMCAAA.mwh@cs.umd.edu \
    --to=mwh@cs.umd.edu \
    --cc=bwv211mail@yahoo.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).