Re: inbox without an out!

From: rex (rex@ptw.com)
Date: Tue, 14 Jul 1998 12:50:52 -0700

Howard Schwartz <theo@ncal.verio.com> wrote:
>> The message format is very simple, for each message you first get four
>> bytes with the length of the message, then the message itself.
>
>You said the bytes that describe message length are ``in binary''. What
>code is used for the number of bytes - hex, octal?

The 4 bytes are a base 256 number representing
the length of the message. As I recall there is a difference in byte
order between the SOUP binary format and Yarn's format. In Soup binary,
the decimal length of the message is given by (in BASIC)

ascii(mid$(m$,1,1))*256*256*256 + ascii(mid$(m$,2,1))*256*256_
+ ascii(mid$(m$,3,1))*256 + ascii(mid$(m$,4,1))

where the message format is m$ = b0b1b2b3message_starts_here...

I believe (but have not verified) that the order in Yarn is little-endian,
so the length is

ascii(mid$(m$,3,1))*256*256*256 + ascii(mid$(m$,4,1))*256*256_
+ ascii(mid$(m$,2,1))*256 + ascii(mid$(m$,1,1))

In C the corresponding functions would be asc and substr I suppose.

-rex