tcp_connect.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:ooniprobe-debian 作者: TheTorProject 项目源码 文件源码
def test_connect(self):
        """
        This test performs a TCP connection to the remote host on the
        specified port.
        The report will contains the string 'success' if the test has
        succeeded, or the reason for the failure if it has failed.
        """
        def connectionSuccess(protocol):
            protocol.transport.loseConnection()
            log.debug("Got a connection to %s" % self.input)
            self.report["connection"] = 'success'

        def connectionFailed(failure):
            self.report['connection'] = handleAllFailures(failure)

        from twisted.internet import reactor
        point = TCP4ClientEndpoint(reactor, self.host, int(self.port))
        d = point.connect(TCPFactory())
        d.addCallback(connectionSuccess)
        d.addErrback(connectionFailed)
        return d
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号