<div>Hi</div><div><br></div><div>To close this thread, my solution is to extends FrameDecoder like the following code:</div><div><br></div><div>@ChannelPipelineCoverage(&quot;all&quot;)</div><div>public class MyFrameDecoder extends FrameDecoder {</div>
<div><br></div><div>    @Override</div><div>    protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {</div><div>        // the length field is at 3rd and 4th octet</div>
<div>        if (buf.readableBytes() &lt; 4) {</div><div>            return null;</div><div>        }</div><div>        // The length field is in the buffer.</div><div>        buf.markReaderIndex();</div><div><div>        ...</div>
</div><div><div>        // Read the length field (the payload size)</div></div><div>        int length = buf.readUnsignedShort();</div><div><div><div>        // The actual frame size is header (20) + payload size</div></div>
</div><div>        length += 20;</div><div>        buf.resetReaderIndex();</div><div>        if (buf.readableBytes() &lt; length) {</div><div>            return null;</div><div>        }</div><div>        ChannelBuffer frame = buf.readBytes(length);</div>
<div>        return frame;</div><div>    }</div><div>}</div><div><br></div><div><br></div><div>Thank you!</div><div><br></div><br><div class="gmail_quote">On Thu, Sep 10, 2009 at 9:23 PM, hezjing <span dir="ltr">&lt;<a href="mailto:hezjing@gmail.com">hezjing@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi<div><br></div><div>I have a message containing a fixed length header of 20 bytes, followed by a payload of variable length.</div>
<div>The header contains a 2 bytes length field, indicating the length of the payload (excluding the header).</div>
<div><br></div><div>For example if the message has 10 bytes payload, then the entire frame length is 30 bytes (20 bytes header + 10 bytes of payload),</div><div>and the length field is 10.</div><div><br></div><div>May I know what is the parameter to create <span style="border-collapse:collapse;white-space:pre">LengthFieldBasedFrameDecoder?</span></div>

<div><span style="border-collapse:collapse;white-space:pre"><br></span></div><div><span style="border-collapse:collapse;white-space:pre"><br>
</span></div><div><span style="border-collapse:collapse;white-space:pre">Thank you!</span></div><div><br clear="all">
<br>-- <br><br>Hez<br>
</div>
</blockquote></div><br><br clear="all"><br>-- <br><br>Hez<br>