network byte order

Discussion in 'C Programming' started by Jesse Engle, Feb 27, 2004.

  1. Jesse Engle

    Jesse Engle Guest

    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
     
    Jesse Engle, Feb 27, 2004
    #1
    1. Advertising

  2. Jesse Engle

    ChrisD Guest

    "Jesse Engle" <> 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
     
    ChrisD, Feb 27, 2004
    #2
    1. Advertising

  3. Jesse Engle

    Dan Pop Guest

    In <z3P%b.18060$> "Jesse Engle" <> 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:
     
    Dan Pop, Mar 1, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luke Skywalker

    Network Byte Order ...

    Luke Skywalker, Nov 11, 2003, in forum: Java
    Replies:
    12
    Views:
    9,209
    Steve Horsley
    Nov 14, 2003
  2. DaBeef
    Replies:
    0
    Views:
    350
    DaBeef
    Nov 2, 2005
  3. Evan
    Replies:
    4
    Views:
    794
    Mark Tolonen
    Mar 5, 2009
  4. Robert Evans
    Replies:
    7
    Views:
    301
    Joel VanderWerf
    Nov 15, 2005
  5. Replies:
    11
    Views:
    382
Loading...

Share This Page