On 9/13/10 9:20 AM, Kúti Zsolt wrote:
Hello,

My decoder worked fine until fragmentation of data happend.
Test case is needed to cover this.

Not knowing better I come up with code that feeds my decoder's doDcode()
method with fragmented data.

I am curious how others solve this.

It depends on the protocol you are implementing. In any case, you have to gather the bytes that will produce a message once decoded. This can be done with a CumulativePotocolDecoder if you are usig a text based protocol with a clear limit (new line, a specific char, etc.) If you have a binay protocol, you'll have to handle fragmentation yourself.

The biggest advantage of the CumulativeProtocolDecoder is that not only you can tell it about the message boundary, but it will also call the decode() methd as many time as you have messages to decode (as you may have a fragmented message, you may also receive more than one message in a single buffer).

--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Reply via email to