当前位置: 首页>>代码示例>>Python>>正文


Python internet.TCPClient方法代码示例

本文整理汇总了Python中twisted.application.internet.TCPClient方法的典型用法代码示例。如果您正苦于以下问题:Python internet.TCPClient方法的具体用法?Python internet.TCPClient怎么用?Python internet.TCPClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.application.internet的用法示例。


在下文中一共展示了internet.TCPClient方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testTCP

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import TCPClient [as 别名]
def testTCP(self):
        s = service.MultiService()
        s.startService()
        factory = protocol.ServerFactory()
        factory.protocol = TestEcho
        TestEcho.d = defer.Deferred()
        t = internet.TCPServer(0, factory)
        t.setServiceParent(s)
        num = t._port.getHost().port
        factory = protocol.ClientFactory()
        factory.d = defer.Deferred()
        factory.protocol = Foo
        factory.line = None
        internet.TCPClient('127.0.0.1', num, factory).setServiceParent(s)
        factory.d.addCallback(self.assertEqual, b'lalala')
        factory.d.addCallback(lambda x : s.stopService())
        factory.d.addCallback(lambda x : TestEcho.d)
        return factory.d 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:test_application.py

示例2: testPrivileged

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import TCPClient [as 别名]
def testPrivileged(self):
        factory = protocol.ServerFactory()
        factory.protocol = TestEcho
        TestEcho.d = defer.Deferred()
        t = internet.TCPServer(0, factory)
        t.privileged = 1
        t.privilegedStartService()
        num = t._port.getHost().port
        factory = protocol.ClientFactory()
        factory.d = defer.Deferred()
        factory.protocol = Foo
        factory.line = None
        c = internet.TCPClient('127.0.0.1', num, factory)
        c.startService()
        factory.d.addCallback(self.assertEqual, b'lalala')
        factory.d.addCallback(lambda x : c.stopService())
        factory.d.addCallback(lambda x : t.stopService())
        factory.d.addCallback(lambda x : TestEcho.d)
        return factory.d 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:test_application.py

示例3: testTCP

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import TCPClient [as 别名]
def testTCP(self):
        s = service.MultiService()
        s.startService()
        factory = protocol.ServerFactory()
        factory.protocol = TestEcho
        TestEcho.d = defer.Deferred()
        t = internet.TCPServer(0, factory)
        t.setServiceParent(s)
        num = t._port.getHost().port
        factory = protocol.ClientFactory()
        factory.d = defer.Deferred()
        factory.protocol = Foo
        factory.line = None
        internet.TCPClient('127.0.0.1', num, factory).setServiceParent(s)
        factory.d.addCallback(self.assertEqual, 'lalala')
        factory.d.addCallback(lambda x : s.stopService())
        factory.d.addCallback(lambda x : TestEcho.d)
        return factory.d 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:20,代码来源:test_application.py

示例4: testPrivileged

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import TCPClient [as 别名]
def testPrivileged(self):
        factory = protocol.ServerFactory()
        factory.protocol = TestEcho
        TestEcho.d = defer.Deferred()
        t = internet.TCPServer(0, factory)
        t.privileged = 1
        t.privilegedStartService()
        num = t._port.getHost().port
        factory = protocol.ClientFactory()
        factory.d = defer.Deferred()
        factory.protocol = Foo
        factory.line = None
        c = internet.TCPClient('127.0.0.1', num, factory)
        c.startService()
        factory.d.addCallback(self.assertEqual, 'lalala')
        factory.d.addCallback(lambda x : c.stopService())
        factory.d.addCallback(lambda x : t.stopService())
        factory.d.addCallback(lambda x : TestEcho.d)
        return factory.d 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:21,代码来源:test_application.py

示例5: test_reactorParametrizationInClientMultipleStart

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import TCPClient [as 别名]
def test_reactorParametrizationInClientMultipleStart(self):
        """
        Like L{test_reactorParametrizationInClient}, but stop and restart the
        service and check that the given reactor is still used.
        """
        reactor = MemoryReactor()

        factory = object()
        t = internet.TCPClient('127.0.0.1', 1234, factory, reactor=reactor)
        t.startService()
        self.assertEquals(
            reactor.tcpClients.pop()[:3], ('127.0.0.1', 1234, factory))
        t.stopService()
        t.startService()
        self.assertEquals(
            reactor.tcpClients.pop()[:3], ('127.0.0.1', 1234, factory)) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:18,代码来源:test_application.py

示例6: test_client

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import TCPClient [as 别名]
def test_client(self):
        """
        L{jstrports.client} returns a L{TCPClient} service.
        """
        got = jstrports.client("tcp:DOMAIN:65535", "Factory")
        self.assertIsInstance(got, TCPClient) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:test_jabberjstrports.py

示例7: testConnectionGettingRefused

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import TCPClient [as 别名]
def testConnectionGettingRefused(self):
        factory = protocol.ServerFactory()
        factory.protocol = wire.Echo
        t = internet.TCPServer(0, factory)
        t.startService()
        num = t._port.getHost().port
        t.stopService()
        d = defer.Deferred()
        factory = protocol.ClientFactory()
        factory.clientConnectionFailed = lambda *args: d.callback(None)
        c = internet.TCPClient('127.0.0.1', num, factory)
        c.startService()
        return d 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:test_application.py

示例8: test_reactorParametrizationInClient

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import TCPClient [as 别名]
def test_reactorParametrizationInClient(self):
        """
        L{internet._AbstractClient} supports a C{reactor} keyword arguments
        that can be used to parametrize the reactor used to create new client
        connections.
        """
        reactor = MemoryReactor()

        factory = protocol.ClientFactory()
        t = internet.TCPClient('127.0.0.1', 1234, factory, reactor=reactor)
        t.startService()
        self.assertEqual(
            reactor.tcpClients.pop()[:3], ('127.0.0.1', 1234, factory)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:test_application.py

示例9: test_reactorParametrizationInClient

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import TCPClient [as 别名]
def test_reactorParametrizationInClient(self):
        """
        L{internet._AbstractClient} supports a C{reactor} keyword arguments
        that can be used to parametrize the reactor used to create new client
        connections.
        """
        reactor = MemoryReactor()

        factory = object()
        t = internet.TCPClient('127.0.0.1', 1234, factory, reactor=reactor)
        t.startService()
        self.assertEquals(
            reactor.tcpClients.pop()[:3], ('127.0.0.1', 1234, factory)) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:15,代码来源:test_application.py

示例10: connectTCP

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import TCPClient [as 别名]
def connectTCP(self, host, port, factory, timeout=30, bindAddress=None):
        s = internet.TCPClient(host, port, factory, timeout, bindAddress)
        s.setServiceParent(self.app) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:5,代码来源:compat.py

示例11: __actuallyConnect

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import TCPClient [as 别名]
def __actuallyConnect(self):
        from twisted.application import internet

        f = pb.PBClientFactory()
        internet.TCPClient(self.host_tx, self.port_tx, f)
        creds = UsernamePassword(self.user_tx, self.pswd_tx)
        f.login(creds, self.pbReferenceable
            ).addCallbacks(self.pbCallback, self.couldNotConnect
            ).setTimeout(30
            ) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:12,代码来源:gtkutil.py


注:本文中的twisted.application.internet.TCPClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。