How hostname resolution works
The DNS is used to assign names to computers and systems connected to the internet. Similar to how a phone book can be used to link a phone number to a name, the DNS allows us to link a hostname to an IP address.
When your program needs to connect to a remote computer, such as www.example.com, it first needs to find the IP address for www.example.com. In this book so far, we have been using the built-in getaddrinfo() function for this purpose. When you call getaddrinfo(), your operating system goes through a number of steps to resolve the domain name.
First, your operating system checks whether it already knows the IP address for www.example.com. If you have used that hostname recently, the OS is allowed to remember ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access