why do structs have different sizes across machines?
Garrett Wollman
wollman at emily.uvm.edu
Sat Mar 30 12:16:53 AEST 1991
In article <1991Mar26.065356.577 at thunder.mcrcim.mcgill.edu> mouse at thunder.mcrcim.mcgill.edu (der Mouse) writes:
>In article <77336 at bu.edu.bu.edu>, jdubb at bucsf.bu.edu (jay dubb) writes:
>> Can anyone explain to me why the following short program give the
>> size of the structure as 38 on a Sun 3, and 40 on an Encore Multimax:
>
>The other choice is to put the structure in some portable form for
>transmission over the connection. This could mean anything from
>judicious use of ntohl() and related routines to converting everything
>to text. This slows you down, of course, but in the vast majority of
>the cases the gain in portability and maintainability is worth it.
If one is really intent on sending binary structures across sockets
(presumes 4BSD IPC, so "portability" is already somewhat compromised),
there is a simple solution to the problem. Both the Multimax (this
machine, at any rate) and the Sun-X (for appropriate values of X>=3)
support Sun's XDR, which basically allows you to feed your structure
definition to a compiler, which will create routines to portably
convert the structure into something suitable for sending across a
network, and then convert it back at the other end. [In this day and
age, it's a fair assumption that Most Networked Unix Systems Which Are
Derived From 4BSD Support NFS, and NFS presupposes XDR.]
-GAWollman
PS: For that matter, our SVR3 SGI machines support NFS, too...
Garrett A. Wollman - wollman at emily.uvm.edu
Disclaimer: I'm not even sure this represents *my* opinion, never
mind UVM's, EMBA's, EMBA-CF's, or indeed anyone else's.
More information about the Comp.lang.c
mailing list