zoukankan      html  css  js  c++  java
  • LengthFieldBasedFrameDecoder 参数说明

    LengthFieldBasedFrameDecoder 参数说明
    举例
    数据包格式为
    body长度(4个)+14个字节的版本说明(字符串)+body
    那么LengthFieldBasedFrameDecoder的参数为

    new LengthFieldBasedFrameDecoder1(ByteOrder.LittleEndian, int.MaxValue, 0, 4, 14, 18, true)
    

    他的构造函数是

    LengthFieldBasedFrameDecoder1(ByteOrder byteOrder, int maxFrameLength, int lengthFieldOffset, int lengthFieldLength, int lengthAdjustment, int initialBytesToStrip, bool failFast)
    


    lengthFieldOffset=0,即长度的偏移字节为零。放在首字节。
    lengthFieldLength=4,长度4个字节。
    lengthAdjustment=14,即修正字节是14,也就是包头长度18-4(4个包头长度),body长度本身不包含包头长度,所以用来计算实际帧长度的左右。

    initialBytesToStrip=18,即跳过包头18个字节。直接读取body.如果要验证包头的参数。则不能跳过

  • 相关阅读:
    POJ 2136
    POJ 2121
    POJ 2127
    POJ 2126
    POJ 2109
    POJ 2105
    POJ 2101
    POJ 2075
    Uboot — 配置过程
    Uboot — 编译体验
  • 原文地址:https://www.cnblogs.com/ruxia/p/12058505.html
Copyright © 2011-2022 走看看