David Rosenstrauch wrote:
David Rosenstrauch wrote:
Emmanuel Lecharny wrote:
I would add a forth case :
* more than one complete message in a single buffer.
In this case, you have to loop until you have decoded all the
messages, calling the next filter for each decoded message.
This is what we do in Apache Directory to decode LDAP requests.
Hmmm ... I might not actually be handling this case. I'll have to
check my code.
Thanks much for the heads up.
DR
Question:
So say in my decoder I do as follows:
public class BinaryProtocolDecoder extends CumulativeProtocolDecoder {
protected boolean doDecode(IoSession session, IoBuffer in,
ProtocolDecoderOutput out) {
...
MyMessage msg = decodeOneMessage(in);
return true;
}
}
i.e., I decode one message from out of the buffer, and leave any
remaining bytes that are part of the next message left unread in the
buffer.
Are those remaining bytes from the next message lost? And if they're
not lost, will the CumulativeProtocolDecoder then immediately call my
doDecode method again to try to decode that message?
They won't be lost, it's just that the buffer will keep them until it
receives more bytes. It has a bad side effect that you may wait forever
if you receive 3 messages in two byte buffer :
- the first message will be processed, and the first part of the second
message will remain in the buffer
- when receiving the second part of the second message plus the third
message, you will process the second message, and the third will remain
for ever in the buffer (until the session is killed)
DR
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org