[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Big-endian/little-endian (WAS: Re: can I burn the output of mpg123 -s?)



Quoting Stephen J. Carpenter (sjc@delphi.com):
> The authors concern was that on a big endian system network order and
> byte order are the same so hton* and ntoh* do nothing....so how do you
> do the swapps...
> I suggested a union first (like below) but...whats the "proper" way of
> doing it? 

The solution is to always run hton before putting stuff on the wire and
running ntoh when pulling stuff back.  That way you can be sure that the
stuff on the wire is always network byte order without having to put in
nasty test cases.

Mike Stone


Reply to: