[Twisted-Python] Finding peers.

screwtape at froup.com screwtape at froup.com
Tue Jul 8 04:38:18 MDT 2003


On Tue, Jul 08, 2003 at 10:49:40AM +0300, Tommi Virtanen wrote:
> On Mon, Jul 07, 2003 at 11:38:38PM +1000, Tim Allen wrote:
> > DNS-SD (DNS based Service Discovery) is the easy part - it's just a  
> > standard way of organising DNS records such that a set of DNS queries  
> > can create a useful list of things to connect to. 'Implementing' DNS-SD  
> > support is not at all difficult, providing there exists an API to  
> > request PTR and SRV records, and providing you can add them to your DNS  
> > server.
> 
> 	That exists, start reading from
> 	twisted.internet.utils.SRVConnector.

I see. Thanks!

> > I haven't read the mDNS spec in detail, but the interaction between  
> > Twisted and the operating system's resolver seems complex. It'd be nice  
> > if Python had a DNS API more extensive than gethostbyname(), but it  
> > doesn't.
> 
> 	That's why Twisted (and many other serious projects) are totally
> 	ignoring the libc resolver. The API is just too limited.
> 
> 	Let me say that again. Twisted implements its own resolver that
> 	talks UDP itself. gethostbyname() is just not usable.

Hm.. ISTR someone saying a while ago that Twisted should use the
operating system's resolver, since it might have a far more complex
configuration than Twisted can read from /etc/resolv.conf - indeed,
here on OS X, /etc/resolv.conf is a just a file written to keep legacy
Unix apps happy - the real resolver seems to have something to do with
this strange /etc/resolver directory I've just discovered.

Anyway, I just looked up ReactorBase._internalResolve() in
twisted.internet.base, and this is what it says:

    def _internalResolve(self, name, timeout):
        try:
            address = socket.gethostbyname(name)
        except socket.error:
            return defer.fail(failure.Failure(error.DNSLookupError("address not found")))
        else:
            return defer.succeed(address)

Granted, ReactorBase.resolve() doesn't call _internalResolve if a new resolver
has been installed (ReactorBase.installResolver()), but a quick grep
of the Twisted source shows no mention of that method apart from its
definition (in ReactorBase and IReactorPluggableResolver).

-- 
 ___________ ____________________________
| Screwtape | Reply-To: munged on Usenet |________ ______ ____ __ _  _   _
|
| "Triangle?" "Yes?" "Where am I?" "Down" "Thanks" "You're welcome" T&R 20030614
|




More information about the Twisted-Python mailing list