Hi Mike<div><br></div><div>Hmmm ... do you mean the example of the frame like the following?</div><div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-size: x-small;"><-- HEADER 20 bytes --><-- PAYLOAD 14 bytes --></span></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-size: x-small;">+-------+---------+----+-----------------------+</span></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-size: x-small;">| | Length | | Payload |</span></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-size: x-small;">| | 0x000C | | |</span></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-size: x-small;">+-------+---------+----+-----------------------+</span></font></div>
<div><span class="Apple-style-span" style="font-size: x-small;"><br></span></div><div><span class="Apple-style-span" style="font-size: x-small;">Total frame size is 34 bytes.</span></div><div><span class="Apple-style-span" style="font-size: x-small;"><br>
</span></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-size: x-small;"><-- HEADER 20 bytes --><-- PAYLOAD 100 bytes --></span></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-size: x-small;">+-------+--------+-----+------------------------+</span></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-size: x-small;">| | Length | | Payload |</span></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-size: x-small;">| | 0x0064 | | |</span></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-size: x-small;">+-------+--------+-----+------------------------+</span></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-size: x-small;"><br></span></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-size: x-small;">Total frame size is 120 bytes.</span></font></div>
</div><div><br></div><div><br></div><br><div class="gmail_quote">On Sun, Sep 20, 2009 at 1:41 AM, Mike McGrady <span dir="ltr"><<a href="mailto:mmcgrady@topiatechnology.com">mmcgrady@topiatechnology.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word">Could you include an example write with this? The two together, I suspect, will be most helpful to many people, including me.<div>
<br></div><div>Mike</div><div><br><div><div><div></div><div class="h5"><div>On Sep 19, 2009, at 8:11 AM, hezjing wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div class="h5"><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> @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() < 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() < 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"><<a href="mailto:hezjing@gmail.com" target="_blank">hezjing@gmail.com</a>></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></div></div>
_______________________________________________<br>netty-users mailing list<br><a href="mailto:netty-users@lists.jboss.org" target="_blank">netty-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
</blockquote></div><font color="#888888"><br><div>
<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;text-align:auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><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;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<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;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<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;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<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;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<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;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<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;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<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" target="_blank">mmcgrady@topiatechnology.com</a></div>
<div><br></div></div></span><br></div></span><br></div></span><br></div></span><br></div></span><br></div></span><br></span><br>
</div>
<br></font></div></div><br>_______________________________________________<br>
netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><br>Hez<br>
</div>