def connect(self, adapter, ip, port):
""" Establish a new TCP connection and link it with this protocol. """
endpoint = TCP4ClientEndpoint(adapter.reactor, ip, port)
d = connectProtocol(endpoint, self)
def bad_connection(failure):
message = "Could not connect to {}:{}\n {}\n".format(ip, port, failure.getErrorMessage())
raise IOError(message)
d.addErrback(bad_connection)
return d
评论列表
文章目录