convert a string into an Internet address stored in a structure
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int inet_aton( const char *cp, struct in_addr *pin );
The inet_aton() routine interprets the specified character string as an Internet address, placing the address into the structure provided. It returns 1 if the string was successfully interpreted; 0 if the string is invalid.
All Internet addresses are returned in network byte order (bytes are ordered from left to right). All network numbers and local address parts are returned as machine-format integer values.
Using the dot notation, you can specify addresses in one of the following forms:
net.net.host
net.host
All numbers supplied as ``parts'' in a dot notation may be decimal, octal, or hex, as specified in the C language. That is, a number is interpreted as decimal unless it has a leading 0 (octal), or a leading 0x or 0X (hex).
A numeric representation of an Internet address, or 0 if an error occurs.
POSIX 1003.1g (draft)
Safety: | |
---|---|
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
gethostbyname(), getnetent(), inet_addr(), inet_lnaof(), inet_makeaddr(), inet_netof(), inet_network(), inet_ntoa()
/etc/hosts, /etc/networks in the TCP/IP User's Guide