473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

network byte order

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
2 4513
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: sidewinder | last post by:
If it does, and it is going between a little endian and a big endian machines can we byte swap it as an int or long? Or does the mantissa or exponent cross 2 byte boundarys? Can I just call...
0
by: DaBeef | last post by:
I have an IP adress and a port # and I needed them in Network Byte Order. Socket.connect (( ipAddr , portNumber) - how would you do this with python, I am unsure of exactly how python data is...
3
by: Scott | last post by:
I'm writing a C# server application that is reading from a socket sent from a C++ client program. The C++ client program is sending the following data: struct { int stringLen; actual ASCII...
5
by: srikant | last post by:
I am writing a client in C# that needs to communicate over the network to a legacy C++ application that uses Unicode strings. I realize that C# strings are already in Unicode, however, how do I...
2
by: Leonardo D'Ippolito | last post by:
Hi! I have two .NET win apps that need to communicate on a TCP/IP network. 'App A' must ask 'app B' if it's allowed to do some task, and 'app B' must authorize or prohibit it. How can I do...
7
by: simonrigby_uk | last post by:
Hi all, Sorry if this is the incorrect group but I couldn't see anything directly relevant. Can someone confirm for me what happens when two network streams are sent to an application at the...
9
by: Manu | last post by:
Hi, Following code shows how a packet is sent from a client to a server's socket. The file size (fileSizeTemp) is converted to network byte order before sending to the server. *((unsigned...
2
by: Kelvin | last post by:
How can I do a host to network conversion (similar to htonl) in JavaScript? i.e. convert to network byte order irrespective of whether host is little or big endian. TIA, KK
3
by: Sir Psycho | last post by:
Hi, For some reason, when i step over this code, it returns the full byte stream im expecting from the server, however when I let it run with no intervention, it only seems to grab a small chunk...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.