Re: Diff Solaris 10 SPARC & x86



Mr. Chow Wing Siu <wschow@xxxxxxxxxxxxxxxx> wrote:
Andrew Gabriel <andrew@xxxxxxxxxxxxxxxxxxxx> wrote:
Most likely you have the port number in processor-native endian
rather than network endian (which is big-endian, same as sparc
processor native endian, but not x86). This would also be obvious
from a snoop trace. This fault would be before the code snippet
you posted.
--
Andrew Gabriel
--------------------------------

You are absolutely correct. I use ntohs() to convert the port number
and it works fine now. Thank you.

Not that it makes any difference, but the right function would be
htons(), not ntohs():

sin.sin_port = htons(port);

remember: htons = host to network short

For htons() and nthos() it should never be a problem mixing then up, but
for htonl(), ntohl() there could in theory exist a crazy byteorder, so that
the functions produce different results.


--
Daniel
.