Reputation: 1
Am writing a server program in c++ using winsock running on a x86 arch. I was wondering if a client running on a arm based architecture can share data with the server successfully without running into problems since the two architectures use different endianness. Do I have to write some code to convert the endianness before receiving or sending data?
Upvotes: 0
Views: 139
Reputation: 58393
Just make a decision about the endianness of the data to be sent between them, and be consistent on both sides.
Most commonly you would use network byte order, which is big-endian, and use functions like htonl
, ntohl
to convert to and from whatever the host system uses. (If the host system is already big-endian, these functions just do nothing and will usually be optimized out.)
Upvotes: 1