1byteorder(3SOCKET) Sockets Library Functions byteorder(3SOCKET)
2
3
4
6 byteorder, htonl, htonll, htons, ntohl, ntohll, ntohs - convert values
7 between host and network byte order
8
10 cc [ flag... ] file... -lsocket -lnsl [ library... ]
11 #include <sys/types.h>
12 #include <netinet/in.h>
13 #include <inttypes.h>
14
15 uint32_t htonl(uint32_t hostlong);
16
17
18 uint64_t htonll(uint64_t hostlonglong);
19
20
21 uint16_t htons(uint16_t hostshort);
22
23
24 uint32_t ntohl(uint32_t netlong);
25
26
27 uint64_t ntonll(uint64_t hostlonglong);
28
29
30 uint16_t ntohs(uint16_t netshort);
31
32
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
41 These functions are most often used in conjunction with Internet
42 addresses and ports as returned by gethostent() and getservent(). See
43 gethostbyname(3NSL) and getservbyname(3SOCKET).
44
46 See attributes(5) for descriptions of the following attributes:
47
48
49
50
51 ┌─────────────────────────────┬─────────────────────────────┐
52 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
53 ├─────────────────────────────┼─────────────────────────────┤
54 │MT-Level │Safe │
55 └─────────────────────────────┴─────────────────────────────┘
56
58 gethostbyname(3NSL), getservbyname(3SOCKET), inet.h(3HEAD),
59 attributes(5)
60
61
62
63SunOS 5.11 10 Sep 2008 byteorder(3SOCKET)