Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!brl-adm!adm!edw@ius2.cs.cmu.EDU From: edw@ius2.cs.cmu.EDU Newsgroups: comp.lang.c Subject: Re: Byte vs. Word Alignment - (nf) Message-ID: <7022@brl-adm.ARPA> Date: Tue, 21-Apr-87 11:21:28 EST Article-I.D.: brl-adm.7022 Posted: Tue Apr 21 11:21:28 1987 Date-Received: Wed, 22-Apr-87 03:21:29 EST Sender: news@brl-adm.ARPA Lines: 34 In article <6700007@iaoobelix.UUCP>, wagner@iaoobelix.UUCP writes: > > struct foo { > char frob_1; > int frob_2; > }; > > I intended to send something like the above structure as a packet over the > net. You know what happened? The VAX/uVAX produces *8* as sizeof struct foo, > whereas the Sun program yields *6*. The client program, run on the VAX sent > a packet of size 8, and the daemon on the Sun thought the packet size was 6. Comment aside from byte alignment. If the Vax has to interpret that structure (ie needs to use frob_2) , you may find it a problem since byte ordering of integers differ on Vaxen and Suns. I suggest you look at the eXternal Data Representation (XDR) section of the sun networking manual. You may find it a problem to use those since as far as I know, neither Berkley nor Sys V support these networking primatives sign :-(. But suppositely Mach will take care of this by supporting its own version of XDR :-). Well I shall find out. -- Eddie Wyatt They say there are strangers, who threaten us In our immigrants and infidels They say there is strangeness, too dangerous In our theatres and bookstore shelves Those who know what's best for us- Must rise and save us from ourselves Quick to judge ... Quick to anger ... Slow to understand... Ignorance and prejudice and fear [all] Walk hand in hand. - RUSH