Hi Trustin and Netty contributors<div><br></div><div>I have to clarify that English is not my native language and so the previous Javadoc could be good already.</div><div>Thanks for updating the Javadoc and it is definitely clearer than before (at least to me).</div>
<div><br></div><div>In overall, I appreciate the way Javadoc is maintained. I particularly like when there are some basic network details described in the Javadoc like the packet fragmentation described in FrameDecoder. These are indeed very helpful to novice network application developer.</div>
<div><br></div><div><br></div><div>Thank you!</div><div><br></div><div><div><br><div class="gmail_quote">2009/9/25 Trustin Lee (이희승) <span dir="ltr"><<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Here's the revised Javadoc:<br>
<br>
<a href="http://fisheye.jboss.org/browse/Netty/trunk/src/main/java/org/jboss/netty/handler/codec/frame/LengthFieldBasedFrameDecoder.java?r=1741" target="_blank">http://fisheye.jboss.org/browse/Netty/trunk/src/main/java/org/jboss/netty/handler/codec/frame/LengthFieldBasedFrameDecoder.java?r=1741</a><br>
<br>
I'm sure it explains quite a lot about using LengthFieldBasedFrameDecoder now :)<br>
<br>
Let me know if you have anything to add.<br>
<div class="im"><br>
-- Trustin Lee, <a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
<br>
<br>
<br>
</div>2009/9/25 Trustin Lee (이희승) <<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>>:<br>
<div><div></div><div class="h5">> Hmm, I want the Javadoc to be easily understandable without referring<br>
> to the source code. What would you suggest me to fix the<br>
> documentation?<br>
><br>
> -- Trustin Lee, <a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
><br>
> On Wed, Sep 23, 2009 at 3:02 PM, hezjing <<a href="mailto:hezjing@gmail.com">hezjing@gmail.com</a>> wrote:<br>
>> Yes, you're right.<br>
>> I should really create a decoder with LengthFieldBasedFrameDecoder(0xFFFF,<br>
>> 2, 2, 16, 0).<br>
>> I was having problem figuring the correct lengthAdjustment until I found the<br>
>> formula from the LengthFieldBasedFrameDecoder source code:<br>
>> frameLength += lengthAdjustment + lengthFieldEndOffset;<br>
>><br>
>> Again, thanks for your help!<br>
>><br>
>> On Mon, Sep 21, 2009 at 2:45 PM, Trustin Lee (이희승) <<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> Not actually. It is supposed to work with either cases, as there are<br>
>>> lengthAdjustment and initialBytesToStrip.<br>
>>><br>
>>> initialBytesToStrip should be 0 because you don't want the resulting<br>
>>> frame's header stripped out.<br>
>>><br>
>>> lengthAdjustment could be 20 or something close to it because there's<br>
>>> an extra data between the length field and the payload.<br>
>>><br>
>>> The Javadoc says:<br>
>>><br>
>>> "It is particularly useful when you decode a binary message which has<br>
>>> an integer header field that represents the length of the message body<br>
>>> or the whole message."<br>
>>><br>
>>> which means, it works regardless whether the length field includes the<br>
>>> header or not. Am I missing something? Could you suggest where to<br>
>>> improve?<br>
>>><br>
>>> -- Trustin Lee, <a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
>>><br>
>>><br>
>>><br>
>>> On Mon, Sep 21, 2009 at 3:24 PM, hezjing <<a href="mailto:hezjing@gmail.com">hezjing@gmail.com</a>> wrote:<br>
>>> > Hi Trustin<br>
>>> ><br>
>>> > In my case, the length field is the size of the payload (excluding the<br>
>>> > header).<br>
>>> ><br>
>>> > If I read the Javadoc correctly, the LengthFieldBasedFrameDecoder is<br>
>>> > applicable when the length field is the size of the header and payload<br>
>>> > right?<br>
>>> ><br>
>>> > :-)<br>
>>> ><br>
>>> > On Mon, Sep 21, 2009 at 9:39 AM, Trustin Lee (이희승) <<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>><br>
>>> > wrote:<br>
>>> >><br>
>>> >> Hi Hez,<br>
>>> >><br>
>>> >> Thanks for closing this thread with a good answer and sorry that I'm<br>
>>> >> 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>
>>> >><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<br>
>>> >> > <<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<br>
>>> >> >> the<br>
>>> >> >> following code:<br>
>>> >> >> @ChannelPipelineCoverage("all")<br>
>>> >> >> public class MyFrameDecoder extends FrameDecoder {<br>
>>> >> >> @Override<br>
>>> >> >> protected Object decode(ChannelHandlerContext ctx, Channel<br>
>>> >> >> 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,<br>
>>> >> >>> followed<br>
>>> >> >>> by a payload of variable length.<br>
>>> >> >>> The header contains a 2 bytes length field, indicating the length<br>
>>> >> >>> of<br>
>>> >> >>> the<br>
>>> >> >>> payload (excluding the header).<br>
>>> >> >>> For example if the message has 10 bytes payload, then the entire<br>
>>> >> >>> 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<br>
>>> >> >>> 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>
>>> ><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>
>><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>
_______________________________________________<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"><br>-- <br><br>Hez<br>
</div></div>