From: gumartinm Date: Sun, 26 Feb 2012 23:40:33 +0000 (+0100) Subject: Comment with questions about packing, serializing and alginment X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=68d8334923c191d79ad678a4e11c9e028b9f9f62;p=JavaTCPFork%2F.git Comment with questions about packing, serializing and alginment --- diff --git a/Daemon/javafork.c b/Daemon/javafork.c index dc98106..b5cefaf 100644 --- a/Daemon/javafork.c +++ b/Daemon/javafork.c @@ -597,6 +597,16 @@ int fork_system(int socket, char *command, int *returnstatus) //ENDIANNESS indepedent. header.type = htonl(1); header.type = htonl(n); + //PACKING THE STRUCT OR SERIALIZING? + //serializing-> sends the struct one data member at time (using for example writev?) I send + //one field of my struct at time. + //packing-> Compilers often do some amount of padding and alignment, so unless you define + //alignment explicitly (maybe using a #pragma pack()), that size may be different. + + //I think I do not need any of both, because my struct has no padding and it has a defined size + //are you sure ur struct is never going to have padding? if it is unaligned? could my struct be unaligned? + //does the compiler guarantee alignment? + //I do not care about the ENDIANNESS and character set in the payload, I send bytes //and the client application must know what it has to do with them. //TODO: my own protocol to make the client independent of the ENDIANNESS and character set used