This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: Network programming for eCos under linux
- To: "'Andrew Lunn'" <andrew dot lunn at ascom dot ch>
- Subject: RE: [ECOS] Network programming for eCos under linux
- From: "Trenton D. Adams" <tadams at theone dot dnsalias dot com>
- Date: Wed, 8 Aug 2001 09:26:18 -0600
- Cc: "'eCos Disuss'" <ecos-discuss at sourceware dot cygnus dot com>
>
> > This shouldn't pose a problem since I've configured my ARM as
> > little-endian. However, htons (), htonl (), etc should solve that
> > problem anyhow, shouldn't it? I mean as far networking code goes
that
> > is. I would obviously have to be careful about data types between
the
> > two if they were different. It's nice to have the ARM with 32-bit
> > little-endian! Makes my life a lot easier since I'm sending data
to a
> > PC.
>
> The problem is, if your machines both use the same endianness, you
> never know when you have missed out a htons(). If they are different
> endianness, it breaks. That why i like to write network code on a
> mixed Solaris & linux network, just to make sure.
>
If you miss an htons () though, your program won't work anyhow if you're
on a little-endian architecture. Take for instance watching on port 10.
If you don't do an htons () to convert to network byte order (BIG
ENDIAN), then your program would watch on port 2560 instead of 10.