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


Python Packet.fromRawString方法代码示例

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


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

示例1: listenForConnections

# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import fromRawString [as 别名]
 def listenForConnections(srcIP, srcPort):
     sock = Connection.createSocket()
     sock.bind((srcIP, srcPort))
     data, address = sock.recvfrom(Packet.MAX_PACKET_LENGTH)
     conn = Connection(srcIP, srcPort, address[0], address[1], sock)
     conn.buffer.append(Packet.fromRawString(data))
     return conn
开发者ID:ivandariojr,项目名称:RxP,代码行数:9,代码来源:connection.py

示例2: receive

# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import fromRawString [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
开发者ID:ivandariojr,项目名称:RxP,代码行数:21,代码来源:connection.py

示例3: test_serialize_data

# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import fromRawString [as 别名]
 def test_serialize_data(self):
     self.assertEqual(
         Packet.fromRawString(TestPacket.packet.serialize()).data,
         TestPacket.data,
         "Data Flag does not serialize or is not read Correctly"
     )
开发者ID:ivandariojr,项目名称:RxP,代码行数:8,代码来源:test_packet.py

示例4: test_sanityCheck

# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import fromRawString [as 别名]
 def test_sanityCheck(self):
     original = TestPacket.packet
     deserialized = Packet.fromRawString(original.serialize())
     self.assertEqual(original, deserialized)
开发者ID:ivandariojr,项目名称:RxP,代码行数:6,代码来源:test_packet.py


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