I have read from here that,
On a hypothetical "stupid-endian" C implementation where the bytes are neither big-endian (ordered
4321
) nor little-endian (ordered1234
), but ordered for example3214
, you would still havehtonl(ntohl(x))
, buthtonl
andntohl
would not do the same thing, they'd be 8-bit rotations in opposite directions. I hope that no such architecture exists, but it could implement the sockets API thanks to the fact thathtonl
andntohl
are separate functions.
But I can't comprehend and figure out meaning of but htonl
and ntohl
would not do the samething, they'd be 8-bit rotations in opposite directions. What will be happen if they are rotated in opposite ways. How will the funcitons behave logically?
Can you depict and explain its logic?
P.S. It means in this case that implementations of htonl
and ntohl
functions are different and htonl(x) != ntohl(x)