FrameDecoder

Trustin Lee (이희승) trustin at gmail.com
Tue Sep 29 04:51:23 EDT 2009


On Fri, Sep 25, 2009 at 12:41 PM, sohguanh <sohguanh at yahoo.com.sg> wrote:
>
> Qn 1
> DelimiterBasedFrameDecoder(int maxFrameLength...)
>
> I have a custom protocol say a,b,c,d\n where \n is the delimiter but the
> length for a b c d is varying so how do I specify a maxFrameLength if I
> intend to use above class ?

It's the maximum allowed length of the frame to prevent too much
memory consumption.  If you don't care, you can specify
Integer.MAX_VALUE, but I wouldn't do that in production.  Specify a
sane value that fits for your environment.

> Qn 2
> I have a custom protocol such that it look like below
>
> <start_tag><content><end_tag> where content cannot have same values as
> start_tag and end_tag. I intend to use LengthFieldBasedFrameDecoder but read
> the javadoc seem it works differently based on the length stored at the
> header byte.
>
> Do I have to write my own Decoder or can Netty consider to have such
> start_tag,content,end_tag decoder class in the next release ? Like a XML
> decoder class perhaps ?
>
> PS the protocol is like xml tags where there is start and end tag with
> content in between.

Yes, you have to write your own decoder in such a case as it's not a
very common message format.

HTH,

— Trustin Lee, http://gleamynode.net/



More information about the netty-users mailing list