Un-/marshalling (same error below) needs to take care of byte order. Use htonX/ntohX for any numeric bigger than a byte.