users@grizzly.java.net

Re: newbie question about blocking ConnectorHandler.read

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Tue, 15 Jul 2008 17:06:36 -0400

Salut,

hagai wrote:
> Hi,
> I am trying to use grizzly as an async http 1.1 client.

Cool!

I already have code
> from a sync http client which I'd like to use to determine if a full
> response has arrived. I register OP_READ in the onConnect method and if I
> determine that there are not enough bytes in the onRead method I use
> ConnectorHandler.read(byteBuffer, true) to synchronously read the remainder
> of the message.
> My problem is that after I send one request and read one response I never
> get any more onRead events on that ConnectorHandler... is there anything I
> should do after I read synchronously to get more onRead events?

Can you try registering for OP_READ again? That's probably the issue. In
  your CallbackHandler, just do:

key.interestOps(key.interestOps() | SelectionKey.OP_READ);

or if you have a reference to the SelectorHandler, just do:

SelectorHandler.register(key,SelectionKey.OP_READ);

Let us know how it goes.

A+

-- Jeanfrancois



>
> Thanks,
> Hagai.