def resolve(self, name, timeout = (1, 3, 11, 45)): """Return a Deferred that will resolve a hostname. """ if not name: # XXX - This is *less than* '::', and will screw up IPv6 servers return defer.succeed('0.0.0.0') if abstract.isIPAddress(name): return defer.succeed(name) return self.resolver.getHostByName(name, timeout)
def resolve(self, name, timeout=(1, 3, 11, 45)): """Return a Deferred that will resolve a hostname. """ if not name: # XXX - This is *less than* '::', and will screw up IPv6 servers return defer.succeed("0.0.0.0") if abstract.isIPAddress(name): return defer.succeed(name) return self.resolver.getHostByName(name, timeout)
def connect(self, host, port): """ 'Connect' to remote server. """ if self._connectedAddr: raise RuntimeError, "already connected, reconnecting is not currently supported (talk to itamar if you want this)" if not abstract.isIPAddress(host): raise ValueError, "please pass only IP addresses, not domain names" self._connectedAddr = (host, port) self.socket.connect((host, port))
def resolveAddress(self): if isIPAddress(self.addr[0]): self._setRealAddress(self.addr[0]) else: d = self.reactor.resolve(self.addr[0]) d.addCallbacks(self._setRealAddress, self.failIfNotConnected)