On 09/10/2012, at 14:32, Bob Tanner <basic at us.netrek.org> wrote: > On 2012-10-08 23:24:42 +0000, James Cameron said: > > 48 bytes is wrong. 32 bytes is right. Your compiler might be > aligning the structure members for performance. Give a suitable > alignment directive to your compiler. We use __attribute__((packed)) > in the server code. Check the offset to each member using whatever > language facilities are available. In C we can use sizeof() and > offsetof(). > > So here's the debug using Jame's excellent advise. > > typedef struct _youServerPacket > { > char type; /* SP_YOU */ > char pnum; /* Guy needs to know this... */ > char hostile; > char swar; > char armies; > char tractor; > char pad2; > char pad3; > unsigned flags; > long damage; > long shield; > long fuel; > unsigned short etemp; > unsigned short wtemp; > unsigned short whydead; > unsigned short whodead; > } __attribute__ ((packed)) youServerPacketStruct; If you really want types of a known width and signedness you should use stdint.h, then you have.. typedef struct _youServerPacket { int8_t type; /* SP_YOU */ int8_t pnum; /* Guy needs to know this... */ int8_t hostile; int8_t swar; int8_t armies; int8_t tractor; int8_t pad2; int8_t pad3; uint8_t flags; int32_t damage; int32_t shield; int32_t fuel; uint16_t etemp; uint16_t wtemp; uint16_t whydead; uint8_t whodead; } __attribute__ ((packed)) youServerPacketStruct; This will always give you the same answer no matter the size of int/long/etc.. -- Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C