Reputation: 1101
If I use ntohl() on an integer which is already in host byte order will that cause any problems?
If not, how does the ntohl() function know its argument is already in host byte order?
Upvotes: 1
Views: 1585
Reputation: 54325
You are asking "If I call ntohl() on an integer twice, will it cause a problem?"
The answer is "Yes."
This should be obvious if you think about the name of the function. It is named "Network to Host Long". After calling this function the integer is now in host byte order not in network byte order.
Upvotes: 0
Reputation: 40830
It doesn't know. It assumes it's given an integer in network byte order and converts it to host, if necessary - that is all.
Upvotes: 1
Reputation: 182619
Your question doesn't make any sense. For ntohl
nothing is high-order or low-order.
Upvotes: 3