volt
volt

Reputation: 1

I am using arm based arch to send data to a x86 based arch. do I have to write code to change the endianness before sending or receiving data?

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

Answers (1)

Nate Eldredge
Nate Eldredge

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

Related Questions