[Python-Dev] Socket module corner cases

Andrew McNamara andrewm at object-craft.com.au
Wed May 31 04:15:16 CEST 2006


>After a little more investigation here, it appears that getfqdn() returns
>the name unchanged (or perhaps run through the system's resolver libs) if
>there's no reverse DNS PTR entry. In the case given above,
>otherbox.mydomain.com didn't have a reverse DNS entry, so getfqdn()
>returned 'OTHERBOX'. However, when getfqdn() is called with a name whose
>IP *does* have a PTR record, it returns the correct FQDN.

That sounds entirely plausible.

Many of these name resolver functions pre-date DNS, and show their
/etc/hosts heritage somewhat (gethostbyaddr returning ip, names and
aliases in one hit is a classic example - this isn't easy with DNS).

>Thanks for the help. Now, couple more questions:
>
>getnameinfo() accepts the NI_NAMEREQD flag. It appears, though that a name
>lookup (and associated error if the lookup fails) occurs independent of
>whether the flag is specified. Does it actually do anything?
>
>Does getnameinfo() support IPv6? It appears to fail (with a socket.error
>that says "sockaddr resolved to multiple addresses") if both IPv4 and IPv6
>are enabled.

Someone more knowledgeable will have to answer these.

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/


More information about the Python-Dev mailing list