In <z3******************@newssvr31.news.prodigy.com > "Jesse Engle" <je****@elementalsn.com> writes:
i'm learning how to do some basic low-level network programming. the site
i'm reading talks about "network byte order" and "host byte order". the
thing is, it doesn't give an explanation as to what they are.
i understand most of what the main socket functions do, but i don't
understand what's up with this network byte order stuff.
could someone explain?
If you're not familiar with the concept of byte order, look it up.
The network byte order is big endian. The host byte order, is whatever
the host actually running your program makes it to be (usually either
little endian or big endian). So, whenever you need to supply
some data in network byte order, be sure to use the conversion
functions/macros described in your network programming tutorial.
Ditto for the case when you get data in the network byte order,
but want to use it on your local host.
Having the network impose a certain byte order makes data exchanges
between hosts using different byte orders possible. Be *very* careful
with the networking API functions, because, if you supply the data in the
wrong byte order, the bug(s) won't be easy to find. Especially if your
host uses the same byte order as the network and the conversion functions
are no-ops.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email:
Da*****@ifh.de