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

Domain Name Lookup

Human beings tend to prefer dealing with hostnames rather than working with raw IP addresses, even if the IP address is in a nice user-friendly presentation format. DNS, short for Domain Name Service, is the mechanism for translating human-readable hostnames, like www.bignerdranch.com, into a corresponding IP address.

You will use struct hostent when looking up hostnames to resolve the address.

s​t​r​u​c​t​ ​h​o​s​t​e​n​t​ ​{​
 ​ ​ ​ ​c​h​a​r​ ​ ​ ​*​h​_​n​a​m​e​;​
 ​ ​ ​ ​c​h​a​r​ ​ ​*​*​h​_​a​l​i​a​s​e​s​;​
 ​ ​ ​ ​i​n​t​ ​ ​ ​ ​ ​h​_​a​d​d​r​t​y​p​e​;​
 ​ ​ ​ ​i​n​t​ ​ ​ ​ ​ ​h​_​l​e​n​g​t​h​;​
 ​ ​ ​ ​c​h​a​r​ ​ ​*​*​h​_​a​d​d​r​_​l​i​s​t​;​
 ​ ​ ​ ​#​d​e​f​i​n​e​ ​h​_​a​d​d​r​ ​ ​h​_​a​d​d​r​_​l​i​s​t​[​0​]​
}​;​

The elements ...

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