From: Jason Daly (jdaly++at++ist.ucf.edu)
Date: 11/13/2001 07:45:55
On Tue, 13 Nov 2001, Rob Body wrote:
> Hi Performer friends,
>
> This is a little off subject but I am integrating some networking into my
> Performer app so that I can update my position from an external source and
> when receiving a 2 byte number that I know should be 2, I receive 512. This
> is obviously a byte ordering problem so I have used ntohs to try and swap
> the ordering of the bytes but I still get 512 after using ntohs.
>
> Does anyone know how I can successfully swap the order of the bytes ??
>
> Any help is much appreciated.
>
Make sure the other side is sending in the correct byte order as well.
If you call ntohs() on a machine that uses network byte order (big-endian)
natively, it won't do anything. So, if you send your packet from a PC
without calling htons() and receive on an SGI IRIX workstation, it will
always be in the wrong order, even if you call ntohs().
--"J"
"I'm a castaway stranded in a desolate land,
I can see the footprints in the virtual sand."
--Neil Peart
This archive was generated by hypermail 2b29 : Tue Nov 13 2001 - 07:44:38 PST