users@grizzly.java.net

Re: newbie question about blocking ConnectorHandler.read

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Fri, 18 Jul 2008 14:13:25 -0400

Salut,

hagai wrote:
> OK... So is this behavior by design? (getting an onRead notification when
> there are no bytes available)

Can you elaborate? You are getting called (onRead) and when you try to
read, there is no bytes?


> One more thing - I want to toggle the read flag back to "on" in the method
> that sends the request. Can I get the key via the connectorHandler (or any
> other way not in the onRead method)

Yes, just do in your callback handler:

SelectionKey key;

onRead(....){
   if (key == null) {
      Context context = ioEvent.attachment();
      key = ctx.getSelectionKey();
   }

}

You can do the same trick inside the onConnect as well.

Hope that help.

- Jeanfrancois


>
> Thanks,
> Hagai.