DOCUMENT ID: 1499-02 SYNOPSIS: Client server programs between Solaris on SPARC and x86. OS RELEASE: Solaris 2.4 PRODUCT: KEYWORDS: SPARC x86 sockets client server htonl htons ntohl ntohs SYMPTOMS: Client server programs don't work between SPARC and x86 DESCRIPTION: Client server programs that work fine between SPARC machines fail to work between SPARC and x86. The programs work fine between SunOS 4.1.x and 5.x on the SPARC. They even work well between Interactive Unix and Solaris x86. But they do not work between SPARC and x86. SOLUTION: SPARC and x86 have different byte ordering. One uses the little endian and the other uses the big endian format. So any communication between them should be done in a common external data representation. This data representation is called Network Byte Ordering. Solaris supports a set of functions for converting from host byte ordering to network byte ordering. The htonl & htons routines are used for converting 32/16 bit host byte ordered quantities to network byte ordered quantities. The ntohl & ntohs routines are used for the reverse conversion. In some architecture as the hostbyte order and the network byte order are the same these routines are defined as null functions. On the other architecture these routines perform real translations. For example if you want to use the port number 601 to communicate between your client and your server then... sin.sin_port = 601 # is the wrong way sin.sin_port = htons(601) # is the right way DATE APPROVED: 09/05/95