> Let's say I have the following message struct that I pass
> around.
> 
> struct packet {
>   u_char  type;
>   u_long  length;
>   int     foo;
>   u_short bar;
> };
> 
> When I go from a 32-bit to 64-bit machine, I could have sworn
> that the "int" was architecture dependent and not the "long".
> According to Steven's UNP vol1, it says that the "int" will stay at
> 32-bits and the long as 64-bits.  Also that the "short" will stay at
> 16-bits.
> 
> Is this a right?

Don't use char, long, int or short.  Use things like u_int_32 and u_int_16.
Better yet, do you really want to pass around binary structures?  Then
you need to worry about endianness, etc.

Unless you can show that performance of getting this data to/from the
wire is your bottleneck, use an ASCII protocol with key/value pairs:

type=X
length=1234
int=-314159
bar="there once was a man from peru"

It's much more portable.

-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to