Hi Yi,
you're right by default FilterChain is executed only when OP_READ is
ready.
You can change it by overriding default accept logic.
Like example bellow:
TCPSelectorHandler sh = new TCPSelectorHandler() {
public boolean onAcceptInterest(SelectionKey key,
Context ctx) throws IOException{
SelectableChannel channel = acceptWithoutRegistration(key);
if (channel != null) {
configureChannel(channel);
SelectionKey readKey =
(1) channel.register(selector, SelectionKey.OP_READ
| SelectionKey.OP_WRITE);
readKey.attach(System.currentTimeMillis());
}
return false;
}
}
at line (1) we register also for OP_WRITE operation.
Hope this helps.
WBR,
Alexey.
On Jun 15, 2008, at 14:45 , JianXing Yi wrote:
> Hi there,
>
> Think about RFC865, the quote of day protocol. The server sends the
> quote of day to the client once accepted the client's connecting. I
> use a protocol chain to implement the server. It seems that the
> server's protocol chain executed only when it received data from
> client. In another word, the server's protocol chain execution is
> triggered by a SelectionKey.OP_READ event by default, I think. Can I
> change it to SelectionKey.OP_WRITE so that the server could initiate
> the interaction with the client?
>
> The attached is the server's code. I tried it with the TELNET
> command line. It showed that the command line has to input to
> initiate the interaction, otherwise it could not get the push from
> the server.
>
> Any help is highly appreciated!
>
> Regards,
> -Yi Bing
> <
> QodServer
> .zip
> >---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net