Re: Magic numbers

Dror Harari <[email protected]> Sun, 21 Jul 2002 00:44:52 -0700
Newsgroups gmane.comp.windows.devel.dime
Message-ID <DIME%[email protected]>
>>DIME can carry arbitrary binary data, so it is highly doubtful
>>that you can guess a magic number that is less likely to
>>appear than any other set of bytes.  It also requires a
>>streaming protocol, so making it per-record (or chunk) doesn't
>>seem necessary.

An executable can also carry arbitrary binary data and still a magic
number is used. The magic number is not used anywhere in the stream but at
the head, typically as the first bytes of the stream.

If, for example, we use 'd', 'I', 'M', 'e' (0x64494D65 big endian) as the
magic number at the head of the DIME message stream, then it will be
highly unlikely to see other streams starting with the same number. Magic
numbers are not intended to be unique, rather, they are intended to
provide high enough certainty (that's the reason for the funny casing).

Java class files, for example, start with the magic number 'Cafe Babe' (in
hex 0xCAFEBABE). I tried to think about similarly inspired magic number
for DIME but could not... still the benefit of a magic number are there
and I have yet to understand why DIME does not have one.