Address Conversions
There are two fundamental forms for IP addresses. The first is a human-readable “presentation” form, such as the IPv4 dotted-quad or the IPv6 colon-delimited hex address. The other is a binary format “network” form that can be used by the sockets API to actually send data across the network. The presentation address is what the user interacts with, and the network form is used by the program’s code.
IPv4- and IPv6-compatible functions
The inet_pton() function converts from an address in presentation format to one in network format, hence the “P to N” in the function name.
int inet_pton (int addressFamily, const char *sourceBuffer, void *destinationAddress); ...
Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.