1inet_pton(3) Linux Programmer's Manual inet_pton(3)
2
3
4
6 inet_pton - Create a network address structure
7
9 #include <sys/types.h>
10 #include <sys/socket.h>
11 #include <arpa/inet.h>
12
13 int inet_pton(int af, const char *src, void *dst);
14
16 This function converts the character string src into a network address
17 structure in the af address family, then copies the network address
18 structure to dst.
19
20 inet_pton(3) extends the inet_addr(3) function to support multiple
21 address families, inet_addr(3) is now considered to be deprecated in
22 favor of inet_pton(3). The following address families are currently
23 supported:
24
25 AF_INET
26 src points to a character string containing an IPv4 network
27 address in the dotted-quad format, "ddd.ddd.ddd.ddd". The
28 address is converted to a struct in_addr and copied to dst,
29 which must be sizeof(struct in_addr) bytes long.
30
31 AF_INET6
32 src points to a character string containing an IPv6 network
33 address in any allowed IPv6 address format. The address is con‐
34 verted to a struct in6_addr and copied to dst, which must be
35 sizeof(struct in6_addr) bytes long.
36
37 Certain legacy hex and octal formats of AF_INET addresses are not sup‐
38 ported by inet_pton(), which rejects them.
39
41 inet_pton() returns a negative value and sets errno to EAFNOSUPPORT if
42 af does not contain a valid address family. 0 is returned if src does
43 not contain a character string representing a valid network address in
44 the specified address family. A positive value is returned if the net‐
45 work address was successfully converted.
46
48 POSIX.1-2001.
49
51 inet_ntop(3)
52
54 AF_INET6 does not recognize IPv4 addresses. An explicit IPv6-mapped
55 IPv4 address must be supplied in src instead.
56
57
58
59Linux Man Page 2000-12-18 inet_pton(3)