Resolving IPS domains, addresses, and managing exceptions
Throughout this section, we'll review useful methods for obtaining more information about an IP address or domain, including the management of exceptions.
Most of today's client-server applications, such as browsers, implement Domain Name Resolution (DNS) to convert a domain to an IP address.
The domain name system was designed to store a decentralized and hierarchically structured database, where the relationships between a name and its IP address are stored.
Gathering information with sockets
The socket module provides us with a series of methods that can be useful to us in the event that we need to convert a hostname into an IP address and vice versa.
Useful methods for gathering more information about an IP address or hostname include the following:
gethostbyaddr(address)
: This allows us to obtain a domain name from the IP address.gethostbyname(hostname)
: This allows us to obtain an...