inet(3) Library Functions Manual inet(3) inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof - (libc -lc) #include #include #include int inet_aton(const char *cp, struct in_addr *inp); in_addr_t inet_addr(const char *cp); in_addr_t inet_network(const char *cp); [[deprecated]] char *inet_ntoa(struct in_addr in); [[deprecated]] struct in_addr inet_makeaddr(in_addr_t net, in_addr_t host); [[deprecated]] in_addr_t inet_lnaof(struct in_addr in); [[deprecated]] in_addr_t inet_netof(struct in_addr in); glibc ( feature_test_macros(7)): inet_aton(), inet_ntoa(): glibc 2.19: _DEFAULT_SOURCE glibc 2.19 ( 2.19): _BSD_SOURCE || _BSD_SOURCE inet_aton() cp IPv4 ( ) inp. inet_aton() . cp : a.b.c.d . a.b.c a b . c 16 . B (). a.b a . b 24 . A (). a a 32 . ( 0) ( 0X). IPv4 . IPv4 ( : IPv4 ). inet_aton() 1 0 ( errno ). inet_addr() cp IPv4 . INADDR_NONE ( -1). -1 (255.255.255.255). inet_aton() inet_pton(3) getaddrinfo(3) . inet_network() cp IPv4 . . -1. inet_ntoa() in IPv4 . . inet_lnaof() in. . inet_netof() in. . inet_makeaddr() inet_netof() inet_lnaof(). net host . in_addr inet_ntoa() inet_makeaddr() inet_lnaof() inet_netof() : typedef uint32_t in_addr_t; struct in_addr { in_addr_t s_addr; }; attributes(7). +----------------------+------------------------------------+---------------------------------------------------------------------------------------------+ | | | | +----------------------+------------------------------------+---------------------------------------------------------------------------------------------+ |inet_aton(), | | (locale) (MT-Safe) | |inet_addr(), | | | |inet_network(), | | | |inet_ntoa() | | | +----------------------+------------------------------------+---------------------------------------------------------------------------------------------+ |inet_makeaddr(), | | MT-Safe | |inet_lnaof(), | | | |inet_netof() | | | +----------------------+------------------------------------+---------------------------------------------------------------------------------------------+ inet_addr() inet_ntoa() POSIX.1-2008. inet_aton() . inet_addr() inet_ntoa() POSIX.1-2001 4.3BSD. inet_lnaof() inet_netof() inet_makeaddr() . IPv4 : A 0 ( ). . B 10 . . C 110 . . (CIDR) ( ). x86 ( ) ( ). inet_aton() inet_ntoa() . : $ ./a.out 226.000.000.037 # Last byte is in octal 226.0.0.31 $ ./a.out 0x7f.1 # First byte is in hex 127.0.0.1 #define _DEFAULT_SOURCE #include #include #include int main(int argc, char *argv[]) { struct in_addr addr; if (argc != 2) { fprintf(stderr, "%s \n", argv[0]); exit(EXIT_FAILURE); } if (inet_aton(argv[1], &addr) == 0) { fprintf(stderr, "Invalid address\n"); exit(EXIT_FAILURE); } printf("%s\n", inet_ntoa(addr)); exit(EXIT_SUCCESS); } byteorder(3), getaddrinfo(3), gethostbyname(3), getnameinfo(3), getnetent(3), inet_net_pton(3), inet_ntop(3), inet_pton(3), hosts(5), networks(5) 3 . . : . 6.18 8 2026 inet(3)