Hostname resolution is a vital part of network programming. It allows us to use simple names, such as www.example.com, instead of tedious addresses such as ::ffff:192.168.212.115. The mechanism that allows us to resolve hostnames into IP addresses and IP addresses into hostnames is the Domain Name System (DNS).
In this chapter, we begin by covering the built-in getaddrinfo() and getnameinfo() socket functions in more depth. Later, we will build a program that does DNS queries using User Datagram Protocol (UDP) from scratch.
We will cover the following topics in this chapter:
- How DNS works
- Common DNS record types
- The getaddrinfo() and getnameinfo() functions
- DNS query data structures
- DNS UDP protocol
- DNS TCP fallback
- Implementing a DNS query program