inet_pton |
Prototype: |
#include <arpa/inet.h>
int inet_pton(int domain, const char* prsnt, void *addr);
|
General Description: |
Converts a human-readable IPv4 or IPv6 address from the dot-/colon-notation to the binary, network-byte ordered form. |
Return Value: |
NONZERO if everything goes well. If an error occurs, the call returns a zero. |
Parameters |
domain |
The network type (AF_INET or AF_INET6). |
prsnt |
The ASCII string of the IP address (for example, 187.34.2.1 or FFFF::8090:A03:3245). |
addr |
The destination. Typically, you would populate the sin_addr field from the sockaddr_in structure or sin6_addr field from the sockaddr_in6 structure. |
Possible Errors |
(errno not set) |
|
|
Examples |
struct sockaddr_in addr;
if ( inet_pton(AF_INET6, "FF02::6790:90A", &addr.sin6_addr) == 0 )
perror("inet_pton() failed");
|