本文整理汇总了Python中twisted.test.proto_helpers.MemoryReactor.listenTCP方法的典型用法代码示例。如果您正苦于以下问题:Python MemoryReactor.listenTCP方法的具体用法?Python MemoryReactor.listenTCP怎么用?Python MemoryReactor.listenTCP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.test.proto_helpers.MemoryReactor
的用法示例。
在下文中一共展示了MemoryReactor.listenTCP方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_listenDefaultHost
# 需要导入模块: from twisted.test.proto_helpers import MemoryReactor [as 别名]
# 或者: from twisted.test.proto_helpers.MemoryReactor import listenTCP [as 别名]
def test_listenDefaultHost(self):
"""
L{MemoryReactor.listenTCP}, L{MemoryReactor.listenSSL} and
L{MemoryReactor.listenUNIX} will return an L{IListeningPort} whose
C{getHost} method returns an L{IAddress}; C{listenTCP} and C{listenSSL}
will have a default host of C{'0.0.0.0'}, and a port that reflects the
value passed, and C{listenUNIX} will have a name that reflects the path
passed.
"""
memoryReactor = MemoryReactor()
for port in [memoryReactor.listenTCP(8242, Factory()), memoryReactor.listenSSL(8242, Factory(), None)]:
verifyObject(IListeningPort, port)
address = port.getHost()
verifyObject(IAddress, address)
self.assertEqual(address.host, "0.0.0.0")
self.assertEqual(address.port, 8242)
port = memoryReactor.listenUNIX(b"/path/to/socket", Factory())
verifyObject(IListeningPort, port)
address = port.getHost()
verifyObject(IAddress, address)
self.assertEqual(address.name, b"/path/to/socket")