[sldev] Variable blocks in UDP-Messages - documentation problem
on the Wiki.
Argent Stonecutter
secret.argent at gmail.com
Sat Aug 4 12:32:41 PDT 2007
> "The message template details how many blocks are in the packet, which
> can be a fixed number or a variable number specified in the packet.
> Fixed is straightforward: there are 1, 2, 4, or more of those
> blocks in
> order with no separators. Variable blocks are prepended with either
> one
> or two bytes saying how many there are. If a block is Variable 2 in
> the
> protocol map it uses two bytes in big endian format, so a count of 7
> would be specified with 0x0700. The same approach is used for the
> fields."
This is misleading. I understand what they're trying to say, but what
they're describing is little-endian format: the low byte comes first
in little-endian, the high byte comes first in big-endian.
That is, two bytes containing a count of "7" in big-endian format is
"0x00 0x07", in little-endian format it's "0x07 0x00".
If you are on a little-endian machine (intel), if you look at "0x00
0x07" as a word, you will see "0x0700"... but that's because you've
swapped the bytes. On a big-endian machine (power PC) you'll see
"0x0007". The value "0x0007" is stored in big-endian format as "0x00
0x07", in little endian as "0x07 0x00", but it's never "0x0700".
I suspect the best way to correct this on the Wiki would be to refer
to the bytes as bytes, with a separator between them: "00 07" or
"0x00 0x07", or to refer to it as "network order" and not provide an
explicit example but rather include code using "ntohs()" showing how
to read it.
More information about the SLDev
mailing list