1 BYTEORDER(3C) Standard C Library Functions BYTEORDER(3C) 2 3 NAME 4 byteorder, htonl, htonll, htons, ntohl, ntohll, ntohs - convert values 5 between host and network byte order 6 7 LIBRARY 8 Standard C Library (libc, -lc) 9 10 SYNOPSIS 11 #include <sys/types.h> 12 #include <netinet/in.h> 13 #include <inttypes.h> 14 15 uint32_t 16 htonl(uint32_t hostlong); 17 18 uint64_t 19 htonll(uint64_t hostlonglong); 20 21 uint16_t 22 htons(uint16_t hostshort); 23 24 uint32_t 25 ntohl(uint32_t netlong); 26 27 uint64_t 28 ntohll(uint64_t netlonglong); 29 30 uint16_t 31 ntohs(uint16_t netshort); 32 33 DESCRIPTION 34 These functions convert 16-bit, 32-bit, and 64-bit quantities between 35 network byte order and host byte order. On some architectures these 36 routines are defined as NULL macros in the include file <netinet/in.h>. 37 On other architectures, the routines are functional when the host byte 38 order is different from network byte order. 39 40 These functions are most often used in conjunction with Internet 41 addresses and ports as returned by gethostent(3NSL) and 42 getservent(3SOCKET). 43 44 MT-LEVEL 45 Safe 46 47 SEE ALSO 48 inet.h(3HEAD), gethostent(3NSL), getservent(3SOCKET), attributes(5), 49 byteorder(5) 50 51 illumos August 2, 2018 illumos