<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Could you include an example write with this? &nbsp;The two together, I suspect, will be most helpful to many people, including me.<div><br></div><div>Mike</div><div><br><div><div>On Sep 19, 2009, at 8:11 AM, hezjing wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><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("all")</div><div>public class MyFrameDecoder extends FrameDecoder {</div>
<div><br></div><div>&nbsp;&nbsp; &nbsp;@Override</div><div>&nbsp;&nbsp; &nbsp;protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// the length field is at 3rd and 4th octet</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (buf.readableBytes() &lt; 4) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return null;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// The length field is in the buffer.</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;buf.markReaderIndex();</div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;...</div>
</div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Read the length field (the payload size)</div></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int length = buf.readUnsignedShort();</div><div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// The actual frame size is header (20) + payload size</div></div>
</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;length += 20;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;buf.resetReaderIndex();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (buf.readableBytes() &lt; length) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return null;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ChannelBuffer frame = buf.readBytes(length);</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return frame;</div><div>&nbsp;&nbsp; &nbsp;}</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&nbsp;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&nbsp;<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>
_______________________________________________<br>netty-users mailing list<br><a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/netty-users<br></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Mike McGrady</div><div>Principal Investigator AF081-028 AFRL SBIR</div><div>Senior Engineer</div><div>Topia Technology, Inc.</div><div>1.253.720.3365</div><div><a href="mailto:mmcgrady@topiatechnology.com">mmcgrady@topiatechnology.com</a></div><div><br></div></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></span><br class="Apple-interchange-newline">
</div>
<br></div></body></html>