Even better than that (I'd say), use the built-in functions of the OS:

>From the Programmer's Companion:

The byte ordering macros are defined in <unix/netinet_in.h>. They convert an
integer between network byte order and the host byte order.

htonl  Converts a 32-bit integer from host byte order to network byte order.
htons  Converts a 16-bit integer from host byte order to network byte order.
ntohl  Converts a 32-bit integer from network byte order to host byte order.
ntohs  Converts a 16-bit integer from network byte order to host byte order.

Using these would certainly be the strandard in terms of network
commuinication.  Of course, it gets more fun with complex data types, but
it's still workable.

Been a long time since I called these functions, so please read your local C
reference for more details.

- Colin





> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Idries
> Hamadi
> Sent: Wednesday, June 05, 2002 5:18 AM
> To: Palm Developer Forum
> Subject: RE: Byte Ordering.
>
>
> Or even better than that, allow the sender to tell the reciever which byte
> ordering it's using, and then require the reciever to convert it
> to whatever
> it wants. This is (very, very slightly) more efficient, as at
> worst the byte
> ordering is changed only once, while requiring a specific ordering will
> require the byte ordering to be changed twice in the worst case
> (both sender
> and reciever use different byte ordering to the one required for
> transmission). However, if you're only going to use this for a specific
> setup (i.e. Palm to Intel or vice versa) then this is probably
> more trouble
> than it's worth.
>
> > -----Original Message-----
> > From: Colin Mitchell [mailto:[EMAIL PROTECTED]]
> > Sent: 03 June 2002 21:04
> > To: Palm Developer Forum
> > Subject: RE: Byte Ordering.
> >
> >
> > >
> > > >   What effect does byte ordering have on serial communication?
> > > Not much.
> > > If you try to send an UInt16 as 2 bytes you will get a
> > problem (if the
> > > other end works reversed).
> > > Just send it as a text string then.
> > >
> >
> > Even better, write/use the requisite functions to define a consistient
> > ordering between the palm and the other device, whatever it may be.
> >
> >
> >
> >
> > --
> > For information on using the Palm Developer Forums, or to
> > unsubscribe, please see http://www.palmos.com/dev/support/forums/
> >
>
> --
> For information on using the Palm Developer Forums, or to
> unsubscribe, please see http://www.palmos.com/dev/support/forums/
>
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to