O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

i​n​t​ ​i​n​e​t​_​p​t​o​n​ ​(​i​n​t​ ​a​d​d​r​e​s​s​F​a​m​i​l​y​,​ ​c​o​n​s​t​ ​c​h​a​r​ ​*​s​o​u​r​c​e​B​u​f​f​e​r​,​ ​v​o​i​d​ ​*​d​e​s​t​i​n​a​t​i​o​n​A​d​d​r​e​s​s​)​;​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required