【问题标题】:Can someone explain the ProtobufVarint32FrameDecoder code有人可以解释一下 Protobuf Varint 32 帧解码器代码吗
【发布时间】:2012-06-15 09:44:04
【问题描述】:

我正在尝试编写自己的 Protobuf 帧解码器,并以此为基础:

https://github.com/netty/netty/blob/master/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufVarint32FrameDecoder.java

我只是想知道为什么它会创建 new byte[5];

它不只需要读取第一个字节即可获得长度。为什么需要 for 循环?

【问题讨论】:

    标签: netty


    【解决方案1】:

    因为长度表示为可变长度字段,如here 中所述。

    【讨论】:

      猜你喜欢
      • 2016-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-06
      相关资源
      最近更新 更多