By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,201 Members | 937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,201 IT Pros & Developers. It's quick & easy.

network byte order

P: n/a
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?

--
Jesse Engle
Nov 14 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"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?

Hi Jesse

It is the order of the bytes used when the cpu interprets a chunk of
bytes as e.g. an int. Search google for "endian", the first hit gives

http://www.cs.umass.edu/~verts/cs32/endian.html

which describes it better than me.

--
Cheers,
ChrisD
Nov 14 '05 #2

P: n/a
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
Nov 14 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.