QuestionQ48

VerifiedNetwork Interfaces

Using Python’s sockets module, which of the following functions retrieves the IP address of www.giac.org?

Explanation

Python's socket module provides socket.gethostbyname(hostname) specifically to resolve a hostname such as www.giac.org into its IPv4 address, returning the address as a dotted-quad string. This is distinct from socket.gethostbyaddr(), which performs the reverse operation of mapping an IP address back to a hostname, and there is no socket.nslookup or socket.get function in the standard library. Of the offered options, only the one built around the gethostbyname-style call correctly represents the mechanism used to obtain an IP address from a hostname.

Community Discussion

No comments yet. Be the first to start the discussion!