• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to temporarily unregister a SelectionKey to go blocking mode ?

 
Luke Iond
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

that's the matter,

Having to go to blocking mode with a previous Selector-registered SocketChannel to exec a transferFrom(), I have canceled its SelectionKey from the Selector.

After the transferFrom() the SocketChannel should back to noblocking mode with the Selector.

How make it ?

I tried with a selectionKey.cancel().

This works (go to block mode, transferFrom completes) till try to register again the channel with the selector:

selectionKey = socketChannel.register(selector, SelectionKey.OP_READ, null);

ends in a infinite loop (WHY ??).

What am I missing ? Any solution ?

thanks in advance

Luke
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!