<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/1.1.8">
</HEAD>
<BODY>
Mike,<BR>
<BR>
I'm assuming you are doing some programming for networking...<BR>
<BR>
As I remember each compiler / uP should have a macro defined to<BR>
order bytes correctly to send over the TCP/IP/Ethernet network. It's<BR>
something like "htons()." If the machine has correct byte ordering, big-endian<BR>
first as I remember, than the macro preprocesses to not much, else it processes<BR>
to code that reorders bytes.<BR>
<BR>
Quoting the Internet:<BR>
<BR>
The <FONT SIZE="3"><B>htonl()</B></FONT> function converts the long integer <FONT SIZE="3"><I>hostlong</I></FONT> from host byte order to network byte order. <BR>
<BR>
The <FONT SIZE="3"><B>htons()</B></FONT> function converts the short integer <FONT SIZE="3"><I>hostshort</I></FONT> from host byte order to network byte order. <BR>
<BR>
The <FONT SIZE="3"><B>ntohl()</B></FONT> function converts the long integer <FONT SIZE="3"><I>netlong</I></FONT> from network byte order to host byte order. <BR>
<BR>
The <FONT SIZE="3"><B>ntohs()</B></FONT> function converts the short integer <FONT SIZE="3"><I>netshort</I></FONT> from network byte order to host byte order. <BR>
<BR>
On the i80x86 the host byte order is Least Significant Byte first, whereas the network byte order, as used on the Internet, is Most Significant Byte first. <BR>
<BR>
<BR>
"Obey network order. If you're communicating to a remote process, use <FONT SIZE="3"><TT>nto*()</TT></FONT> and <FONT SIZE="3"><TT>*ton()</TT></FONT> to ensure sure all network communications use network byte order."<BR>
<BR>
Hope this helps,<BR>
<BR>
Kirby W. Cartwright<BR>
<BR>
On Thu, 2003-12-04 at 14:54, Mike Harrold wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE><FONT COLOR="#737373" SIZE="3"><I>Hi,
Can anyone point me to a package that does byte swapping?
i.e., little-endian to big-endian conversion.
Thanks,
/Mike
_______________________________________________
colug mailing list
colug@colug.net</FONT>
<A HREF="http://www.colug.net/mailman/listinfo/colug"><FONT SIZE="3">http://www.colug.net/mailman/listinfo/colug</I></FONT></A></PRE>
</BLOCKQUOTE>
</BODY>
</HTML>