Re: Using structs as custom protocol headers
From: Derk Gwen (derkgwen@HotPOP.com)
From: Derk Gwen <derkgwen@HotPOP.com> Date: Wed, 02 Apr 2003 03:26:45 -0000
# Ok. He (the lecturer) thinks structs can be used if "youre carefull",
# i'd like to use them but if you and he say it's difficult then I'd
# probably be foolish to try.
If you're using the same compiler on the same hardware with the same options,
that would be being careful. The problem is that a C compiler will layout the
fields in the same order, but is allowed to put invisible padding bytes in the
layout as well. And different compilers, or different versions of the same
compiler can pad a structure in different ways.
# Ive done a bit of reading on endian-ness and know I have to convert
# the IP and port number, but do I have to convert all the data as
I try do it on all integers I output to a file or socket. That way I know I
can read in on any other machine.
-- Derk Gwen http://derkgwen.250free.com/html/index.html I have no respect for people with no shopping agenda.