本文整理汇总了Python中packet.Packet.checkIntegrity方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.checkIntegrity方法的具体用法?Python Packet.checkIntegrity怎么用?Python Packet.checkIntegrity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类packet.Packet
的用法示例。
在下文中一共展示了Packet.checkIntegrity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: receive
# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import checkIntegrity [as 别名]
def receive(self):
if len(self.buffer) > 0:
return self.buffer.pop()
targetTime = time.time() + (Connection.TIMEOUT * 2)
while targetTime > time.time():
data, address = self.sock.recvfrom(Packet.MAX_PACKET_LENGTH)
otherConnection = next((x for x in Connection.ActiveConnections if x.destAddress == address and x.destAddress != self.destAddress), None)
if address == self.destAddress:
if not Packet.checkIntegrity(data):
return None
return Packet.fromRawString(data)
elif otherConnection != None:
otherConnection.buffer.append(Packet.fromRawString(data))
else:
#if address is not in active connections. Throw packet away
continue
return None
示例2: test_checkIntegrity
# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import checkIntegrity [as 别名]
def test_checkIntegrity(self):
self.assertTrue(
Packet.checkIntegrity(TestPacket.packet.serialize()),
"Simple Packet Failed Integrity Test"
)