"shalu" <sh**********@mail.codecomments.com> wrote in message
news:1102448048.8e5b922fd6d04db5ac9b28e8ac76f28d@t ng...
Hi,
Iam trying to understand Socket programming. I couldnt understand the
functions htons() and htonl(). What is the difference between host byte
order and network byte order ?
"Network byte order" is defined to be big-endian; individual hosts might be
big- or little-endian. To deal with this, the macros/functions htons(),
htonl(), ntohs(), and ntohl() allow you to create code that automatically
changes endianness if necessary on a particular host platform.
Do note that in this context a "short" is defined to be exactly two octets
and a long to be exactly four octets. A C "short" or "long" might be larger
on a particular platform, but will never be smaller.
S
--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking