bluetoothservice.py 文件源码

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

项目:bitpay-brick 作者: javgh 项目源码 文件源码
def read_varint32(sock):
    mask = (1 << 32) - 1
    result = 0
    shift = 0
    while True:
        unpacker = struct.Struct('! B')
        data = sock.recv(unpacker.size, socket.MSG_WAITALL)
        (b,) = unpacker.unpack(data)

        result |= ((b & 0x7f) << shift)
        if not (b & 0x80):
            result &= mask
            return result
        shift += 7
        if shift >= 64:
            raise IOError("Too many bytes when decoding varint.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号