Have you filled up a ticket about the compacting issue?
Have you posted the code for your protocol parser? Here's mine, maybe
you can give me some tips! :.)
I will add your buffer compacting tip!
Simon
-----Original Message-----
From: Erik Svensson [mailto:erik.svensson_at_six.se]
Sent: March-07-08 10:56 AM
To: users_at_grizzly.dev.java.net
Subject: Re: [Q] Testing ProtocolFilter
On 3/7/08 4:40 PM, "Simon Trudeau" <strudeau_at_bluetreewireless.com>
wrote:
> I would like to know, how can I test my protocol filter. I would like
to
> simulate, using unit tests, a truncated message.
>
>
>
> I try invoking the connectorHandler's send() method twice (part1 and
> part2 of my message) with a Thread.sleep in between but the protocol
> parsers doesn't think tokens are missing, it sees the two different
> operations as two different message. Does this has something with
TCP/IP
> where the stack is configured to "know" the packet received has been
> truncated or do I need to investigate my ProtocolFilter further. How
> should I test this?
>
>
>
> client.connect(new
> InetSocketAddress(InetAddress.getLocalHost(), serverPort));
>
> ByteBuffer outputByteBuffer1 = ByteBuffer.wrap(new
> String("\r\nPA").getBytes());
>
> ByteBuffer outputByteBuffer2 = ByteBuffer.wrap(new
> String("SS\r\n\0").getBytes());
>
> client.send(outputByteBuffer1);
>
> Thread.sleep(25);
>
> client.send(outputByteBuffer2);
>
I haven't looked at your previously posted code but I've written a
ProtocolParser. tcp knows nothing about messages nor does it know
anything
about the semantics of your message.
Your ProtocolParser needs to be able to determine if it has received a
complete message and then return true when the 'I need more data'-method
is
called.
I also found that I had to do a compact() on my incoming bytebuffer when
the
ReleaseBuffer() is called.
Otherwise, if you can't read a complete message the bytebuffer will just
fill up until there's no more space and you don't get any more messages.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
For additional commands, e-mail: users-help_at_grizzly.dev.java.net