I wanted to know what byte sorting method my PC uses. So I experimented to see if any u_long variable remains the same after it is converted to the htons() function.
u_long example = 0x12345678;
printf("#%x -> #%x -> #%x\n", example, htonl(example), htonl(htonl(example)));
During the test, I called the htons function once more, and once again, I found that the htons applied function changed the value again.
Output
#12345678 -> #78563412 -> #12345678
Expected
#12345678 -> #78563412 -> #78563412
The htons function sorts all the data into big endian, Why does the data change when called again? What's the problem? Please let me know my mistake.