[Spread-users] byte-order/endiness for payload

Nilo Rivera nrivera at cs.jhu.edu
Mon May 11 22:18:00 EDT 2009

Hello Joseph,

In case you missed it, SP_receive() -- 
http://spread.org/docs/spread_docs_4/docs/sp_receive.html -- has an 
endian_mismatch field that lets you know if there is a mismatch in the 
byte order between the sender and the receiver.  Basically, using this 
field prevents you from wasting cpu-cycles when you don't really need 
any conversion in the fields (as opposed to using htonl).

There are also some conversion utilities available in Spread:

However, sending the struct itself can be an issue, especially if there 
are different types in it (due to alignment/etc in different 
architectures). So you may also want look at how to serialize data for 
network transmission.


Joseph VanAndel wrote:
> What techniques do spread users use to handle byte-order and alignment  
> issues for messages sent via spread?
> For example, if I'm sending a set of parameters
> struct example {
>      int param1;
>      int param2;
>      float f1;
>      float f2;
> };
> from one computer to another computer with different byte order and/or  
> alignment, I can't simply send the byte representation of the structure.
> For integers, I could use the htohl() calls, but there is no standard  
> implementation (that I know of) for network byte order for floats or  
> doubles.  I could also use Sun's xdr or send the parameters using XML.
> Any other suggestions?
> _______________________________________________
> Spread-users mailing list
> Spread-users at lists.spread.org
> http://lists.spread.org/mailman/listinfo/spread-users

More information about the Spread-users mailing list