<div>Hi Trustin</div>
<div> </div>
<div>In my case, the length field is the size of the payload (excluding the header).</div>
<div> </div>
<div>If I read the Javadoc correctly, the LengthFieldBasedFrameDecoder is applicable when the length field is the size of the header and payload right?</div>
<div> </div>
<div>:-)<br><br></div>
<div class="gmail_quote">On Mon, Sep 21, 2009 at 9:39 AM, Trustin Lee (이희승) <span dir="ltr"><<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi Hez,<br><br>Thanks for closing this thread with a good answer and sorry that I'm late.<br><br>Do you find the Javadoc of LengthFieldBasedFrameDecoder difficult to<br>
understand? I thought your use case is explained already there. Let<br>me know what you think so that we can improve the documentation.<br><br>Cheers<br><br>— Trustin Lee, <a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
<div>
<div></div>
<div class="h5"><br><br><br>On Sun, Sep 20, 2009 at 9:12 PM, hezjing <<a href="mailto:hezjing@gmail.com">hezjing@gmail.com</a>> wrote:<br>> Hi Mike<br>> Hmmm ... do you mean the example of the frame like the following?<br>
> <-- HEADER 20 bytes --><-- PAYLOAD 14 bytes --><br>> +-------+---------+----+-----------------------+<br>> | | Length | | Payload |<br>> | | 0x000C | | |<br>
> +-------+---------+----+-----------------------+<br>> Total frame size is 34 bytes.<br>> <-- HEADER 20 bytes --><-- PAYLOAD 100 bytes --><br>> +-------+--------+-----+------------------------+<br>
> | | Length | | Payload |<br>> | | 0x0064 | | |<br>> +-------+--------+-----+------------------------+<br>> Total frame size is 120 bytes.<br>><br>
><br>> On Sun, Sep 20, 2009 at 1:41 AM, Mike McGrady <<a href="mailto:mmcgrady@topiatechnology.com">mmcgrady@topiatechnology.com</a>><br>> wrote:<br>>><br>>> Could you include an example write with this? The two together, I<br>
>> suspect, will be most helpful to many people, including me.<br>>> Mike<br>>> On Sep 19, 2009, at 8:11 AM, hezjing wrote:<br>>><br>>> Hi<br>>> To close this thread, my solution is to extends FrameDecoder like the<br>
>> following code:<br>>> @ChannelPipelineCoverage("all")<br>>> public class MyFrameDecoder extends FrameDecoder {<br>>> @Override<br>>> protected Object decode(ChannelHandlerContext ctx, Channel channel,<br>
>> ChannelBuffer buf) throws Exception {<br>>> // the length field is at 3rd and 4th octet<br>>> if (buf.readableBytes() < 4) {<br>>> return null;<br>>> }<br>
>> // The length field is in the buffer.<br>>> buf.markReaderIndex();<br>>> ...<br>>> // Read the length field (the payload size)<br>>> int length = buf.readUnsignedShort();<br>
>> // The actual frame size is header (20) + payload size<br>>> length += 20;<br>>> buf.resetReaderIndex();<br>>> if (buf.readableBytes() < length) {<br>>> return null;<br>
>> }<br>>> ChannelBuffer frame = buf.readBytes(length);<br>>> return frame;<br>>> }<br>>> }<br>>><br>>> Thank you!<br>>><br>>> On Thu, Sep 10, 2009 at 9:23 PM, hezjing <<a href="mailto:hezjing@gmail.com">hezjing@gmail.com</a>> wrote:<br>
>>><br>>>> Hi<br>>>> I have a message containing a fixed length header of 20 bytes, followed<br>>>> by a payload of variable length.<br>>>> The header contains a 2 bytes length field, indicating the length of the<br>
>>> payload (excluding the header).<br>>>> For example if the message has 10 bytes payload, then the entire frame<br>>>> length is 30 bytes (20 bytes header + 10 bytes of payload),<br>>>> and the length field is 10.<br>
>>> May I know what is the parameter to create LengthFieldBasedFrameDecoder?<br>>>><br>>>> Thank you!<br>>>><br>>>> --<br>>>><br>>>> Hez<br>>><br>>><br>
>><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>
>> <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>>><br>>> Mike McGrady<br>>> Principal Investigator AF081-028 AFRL SBIR<br>
>> Senior Engineer<br>>> Topia Technology, Inc.<br>>> 1.253.720.3365<br>>> <a href="mailto:mmcgrady@topiatechnology.com">mmcgrady@topiatechnology.com</a><br>>><br>>><br>>><br>>><br>
>><br>>><br>>><br>>><br>>><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>><br>><br>><br>> --<br>><br>> Hez<br>><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>><br><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>
</div></div></blockquote></div><br><br clear="all">
<div></div><br>-- <br><br>Hez<br>