1BYTEORDER(3N) BYTEORDER(3N)
2
3
4
6 htonl, htons, ntohl, ntohs - convert values between host and network
7 byte order
8
10 #include <sys/types.h>
11 #include <netinet/in.h>
12
13 netlong = htonl(hostlong);
14 u_long netlong, hostlong;
15
16 netshort = htons(hostshort);
17 u_short netshort, hostshort;
18
19 hostlong = ntohl(netlong);
20 u_long hostlong, netlong;
21
22 hostshort = ntohs(netshort);
23 u_short hostshort, netshort;
24
26 These routines convert 16 and 32 bit quantities between network byte
27 order and host byte order. On machines such as the SUN these routines
28 are defined as null macros in the include file <netinet/in.h>.
29
30 These routines are most often used in conjunction with Internet
31 addresses and ports as returned by gethostbyname(3N) and getserā
32 vent(3N).
33
35 gethostbyname(3N), getservent(3N)
36
38 The VAX handles bytes backwards from most everyone else in the world.
39 This is not expected to be fixed in the near future.
40
41
42
434.2 Berkeley Distribution May 15, 1986 BYTEORDER(3N)