(self)
Connect to the host and port specified in __init__.
Connect to the host and port specified in __init__.
Connect to the host and port specified in __init__ .
def connect(self):
        """Connect to the host and port specified in __init__."""
        msg = "getaddrinfo returns an empty list"
        hostname, aliaslist, ipaddrlist = socket.gethostbyname_ex(self.host)
        for ipaddr in ipaddrlist:
            sa = (ipaddr, self.port)
            try:
                self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                if self.debuglevel > 0:
                    print "connect: (%s, %s)" % (self.host, self.port)
                self.sock.connect(sa)
            except socket.error, msg:
                if self.debuglevel > 0:
                    print 'connect fail:', (self.host, self.port)
                if self.sock:
                    self.sock.close()
                self.sock = None
                continue
            break
        if not self.sock:
            raise socket.error, msg
def connect ( self ) : msg = "getaddrinfo returns an empty list" hostname , aliaslist , ipaddrlist = socket . gethostbyname_ex ( self . host ) for ipaddr in ipaddrlist : sa = ( ipaddr , self . port ) try : self . sock = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) if self . debuglevel > 0 : print "connect: (%s, %s)" % ( self . host , self . port ) self . sock . connect ( sa ) except socket . error , msg : if self . debuglevel > 0 : print 'connect fail:' , ( self . host , self . port ) if self . sock : self . sock . close ( ) self . sock = None continue break if not self . sock : raise socket . error , msg