They will transfer the data as text which will be parsed as an int on the receiving side. None of those formats will transfer an int as 4 bytes. Lets zoom out a little bit to modern network protocols which could be using json or xml.
Obviously it is important to agree on which end to interpret an int. One a little endian system the bytes will be interpreted from right-to-left, and vice-verca on a big endian system. Lets take 4 bytes and interpret them as an int. According to Wikipedia endianness is the order of bytes comprising a word. I dont think any of the answers are quite precise enough. I'm afraid that is not objectively answerable. including on platforms that are natively big-endian.Ģ - Indeed, what does "safe" mean? If you are asking us to predict the future direction of hardware platforms. And deal with version compatibility problems, etcetera.Ĭlearly, most current generation platforms are natively little-endian, but 1) some are not, and 2) we can only guess what will happen in the future.ġ - Always. The applications will break, and you will need to change them to fix the problem. The obvious disadvantage of ignoring endianess is that if you / your users need to run your applications / protocol between platforms with different native endianess, then you have a problem. Is that "safe" 2? That is for you to judge! But certainly there are common hardware platforms that use little-endian, big-endian or. If you design your applications / protocols to send / receive whatever the native endianess is, then they will work as long as you run your applications on platforms with the same native endianess. If you design your applications / protocols to always 1 send little-endian, then you are NOT ignoring endianess. So, my question is: Can I safely ignore the endianess and just send little-endian data? If you have a very large number of messages, find a way to express them and write a program to generate the inbound and outbound conversions.
ANDROID MAC ADDRESS LITTLE BIG ENDIAN CODE
Maintaining the code to do the inbound and outbound conversions isn't really a big effort. Where you'd normally call htons() to put things in the order you need, write a macro called htots() that conditionally compiles to nothing on little-endian architectures and does the re-arranging on big-endian. If you know ahead of time the majority of the systems running your code will be little-endian and performance is critical, declare that the "tkausl standard byte ordering" and go with it. It's big-endian, but nothing says you have to abide by it when designing your protocol. There is a network-standard byte ordering. If you intend for it to have a long life, it's worth the extra effort to avoid disturbing well-proven code a decade from now when some big-endian architecture has become the "in" thing and you find it to be a good market for your application. It's only unnecessary if you can guarantee your code will always run on little-endian architectures.
when I already know that both, server and client run on little endian? Thats just unnecessary work to do.