users@grizzly.java.net

Re: Need help implementing ProtocolParser

From: Erik Svensson <erik_at_flundra.net>
Date: Mon, 17 Mar 2008 20:46:15 +0100

> Erik Svensson-2 wrote:
>>
>> A quick look at the code shows that, as far as Grizzly knows, you
>> aren't
>> doing anything with the incoming byteBuffer. The position is the
>> same when
>> releaseBuffer() is called as it was when startBuffer() was called.
>> Even more important, the buffer is still unread and full when you
>> exit
>> releaseBuffer()!

> grizzly asks protocol parser about the buffer state by calling
> hasMoreBytesToParse() - it do not check the buffer directly - you
> can see
> this here
> https://grizzly.dev.java.net/source/browse/grizzly/trunk/modules/
> grizzly/src/main/java/com/sun/grizzly/filter/
> ParserProtocolFilter.java?rev=668&view=log
> Take a look at execute() and postExecute() methods.

I've done so. However, when you return a NeedMoreBytes grizzly should
use the same bytebuffer as before. If it can't write to that buffer I
don't know what happens. My experience is that nothing will be
written to the buffer.
My first protocol parser did not work until I added a call to compact
() in the releaseBuffer() method.
So, if you haven't tried clearing the buffer, give it a spin. It
might work! :-)


cheers

/Erik

'I wonder if Life ever notices us as it goes past?'