users@grizzly.java.net

Re: newbie question about blocking ConnectorHandler.read

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Thu, 17 Jul 2008 11:22:48 -0400

Salut,

hagai wrote:
> Hi,
> I added the key, it seemed to do the trick.
> However, now I have a new problem. I am getting multiple onRead events on
> the same request, even though I read the whole request from the socket. is
> it possible to get an onRead event without any data arriving on the socket?
> is there any way to tell when this happens?

Yes, inside your onRead(), just do:

key.interestOps(key.interestOps() & (~SelectionKey.OP_READ));

Make sure you register the SelectionKey back once you are ready to
receive more OP_READ.

Thanks

-- Jeanfrancois


>
> Thanks,
> Hagai.