Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

htons(3n) [ultrix man page]

byteorder(3n)															     byteorder(3n)

Name
       htonl, htons, ntohl, ntohs - convert values between host and network byte order

Syntax
       #include <sys/types.h>
       #include <netinet/in.h>

       netlong = htonl(hostlong);
       u_long netlong, hostlong;

       netshort = htons(hostshort);
       u_short netshort, hostshort;

       hostlong = ntohl(netlong);
       u_long hostlong, netlong;

       hostshort = ntohs(netshort);
       u_short hostshort, netshort;

Description
       These routines convert 16-bit and 32-bit quantities between network byte order and host byte order.  On some non-ULTRIX machines these rou-
       tines are defined as null macros in the include file <netinet/in.h>.

       These routines are most often used with Internet addresses and ports as returned by and

Restrictions
       Digital's systems handle bytes in the reverse of most UNIX-based systems.

See Also
       gethostent(3n), getservent(3n)

																     byteorder(3n)

Check Out this Related Man Page

byteorder(3SOCKET)					     Sockets Library Functions						byteorder(3SOCKET)

NAME
byteorder, htonl, htons, ntohl, ntohs - convert values between host and network byte order SYNOPSIS
cc [ flag... ] file... -lsocket -lnsl [ library... ] #include <sys/types.h> #include <netinet/in.h> #include <inttypes.h> uint32_t htonl(uint32_t hostlong); uint16_t htons(uint16_t hostshort); uint32_t ntohl(uint32_t netlong); uint16_t ntohs(uint16_t netshort); DESCRIPTION
These routines convert 16-bit and 32-bit quantities between network byte order and host byte order. On some architectures these routines are defined as NULL macros in the include file <netinet/in.h>. On other architectures, the routines are functional when the host byte order is different from network byte order. The routines are most often used in conjunction with Internet addresses and ports as returned by gethostent() and getservent(). See geth- ostbyname(3NSL) and getservbyname(3SOCKET). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
gethostbyname(3NSL), getservbyname(3SOCKET), inet.h(3HEAD), attributes(5) SunOS 5.10 19 Feb 2004 byteorder(3SOCKET)
Man Page