Every host (actually, every network interface) on the Internet has an internet protocol (IP) address. Most hosts also have human-readable names. Some names correspond to multiple addresses; some addresses correspond to multiple names. The domain name service (DNS) is the distributed database that stores this information. In this lab, we will write code to translate between the two kinds of identifiers by calling library functions that interact with DNS for us.
This lab is a little less well-defined than what you may be accustomed -- you are expected to figure more out yourself (primarily by finding and carefully reading man pages).
Exercises:
gethostbyname()
.
gethostbyaddr()
.
Bonus Exercise:
Note: *** Recall that information can be represented in
many ways.
For example, the number 109 can be stored in one byte (using the char data
type, and equivalent to 'm'), or across two bytes (using the short int
type), or as three bytes (as the array of characters '1', '0', '9' or
their ASCII value equivalents), or across four bytes (using the long int
type). The converse is also true. If, in a particular memory location,
when you read the byte, it could be read as the letter 'm' or as the value
109.
Last revised 28 August 2008, Prof. Davison.