Group: comp.lang.java.programmer
From: coal@mailvault.com
Date: Tuesday, February 26, 2008 5:10 PM
Subject: Re: Java Serializing in C/C++?

On Feb 26, 3:02=A0pm, James Kanze wrote:
> On Feb 26, 9:30 pm, c...@mailvault.com wrote:
>
> > On Feb 25, 2:27 pm, k-e-n wrote:
>
> =A0 =A0 [...]
>
> > > Obviously another thing you can add is the total message
> > > length, again at a fixed location near the beginning of the
> > > message.
> > Do you always use total message lengths? I'm of the opinion
> > that if communication is happening behind a single firewall,
> > the total message lengths can be omitted. =A0That assumes an
> > organization can trust it's employees. =A0For the most part I
> > think that is a safe assumption, but there are some
> > exceptions.
>
> Interestingly, the major use of total message lengths I've seen
> is between processes communicating over a pipe. =A0It's mainly an
> optimization measure, but it can make a significant difference,
> and it can make the code easier to write as well.

I'm not sure why you describe it as an "optimization measure."
It seems to me that not calculating/sending/receiving a total msg
length is simpler if the context permits. What I got out of the
thread on clc++m about denial of service and serialization is that
using a total msg length is important from a security perspective.

>
> > > Create for your self a MessageHeader class and think about
> > > useful things it can contain: Message-Type, Type-Revision,
> > > Element-Count, Byte-Count, ...
> > Why send the Element-Count? =A0It seems redundant given the
> > Message-Type and version number.
>
> It depends. =A0Suppose the Message-Type contains a variable length
> array.
>

You know from the msgid and version number that the message has one
high-level element - a variable length array. And the length of the
array is prepended to the array data as part of the payload. I guess
there is header-like info embedded in the payload the way I think
about it. It could be made part of a header but I'm don't think
there
is anything to be gained from that. If some messages don't have
variable
length data there is a little bit of unnecessary overhead in having a
element count.

Brian Wood

News in English | Binaries Groups | 20lbs in 30 days