HARRIS FLAME Re: SHORT vs. INT
Ron Natalie <ron>
ron at brl-tgr.ARPA
Tue Sep 10 04:40:07 AEST 1985
> To enable network communication between different machines, a "short" is
> guaranteed to be 16-bits and a "long" is guaranteed to be 32-bits. This
> is either convention or standard, I am not sure which.
Actually, it is neither. Assuming short is 16 and long is 32 will get
you into problems. If you have a machine with a word size longer than
32, you have no recourse than to make your longs the length of the word
size, as it is a standard that ints can't be longer than longs.
Those of us who work on 36 and 64 bit machines are well aware of this
problem. The network standard lists the exact bit representation
using pictures, not related to any machine or language. HTONS and the
other byteorder routines are used in 4.2 code to byte swap when necessary.
They are not part of any standard or convention outside of the 4.2. Bit
fields are another source of network problems as there is currently no
standard for the order of bits in a group of fields.
> By the way: WHOLE STRUCTURES SHOULD NEVER BE TRANSMITTED OVER A NET DUE
> TO BYTE ORDER AND ALIGNMENT PROBLEMS.
No matter what you transmit over the net you have to be careful and there
always ends up being some machine dependance somewhere. There is no such
thing as a network alignment problem. The network is a string of octets
(that's eight bit things, can't say bytes because some people actually have
different byte sizes).
> FLAME OF MY OWN:
> People such as Mr. Harris should be aware that not all people participating
> in this forum are experts.
You certainly aren't.
More information about the Comp.lang.c
mailing list