tags:

views:

9

answers:

1

Given a SelectableChannel c and its SelectionKey k, k.isWritable() returns, whether the channel is ready to accept calls to write().

However, can k.isWritable() return true if the channel accepts writes, but OP_WRITE isn't set in interestOps?

+1  A: 

No, ready ops is subset of interest ops. if key isn't interested in write, selector will not set its write ready op (which does not mean it cannot accept write. you can call write() anytime. with write-ready, write() is very likely to succeed, but there's not guarantee there either)

irreputable
It's a different question, but under what circumstances (apart from the connection getting closed between isWriteable() and write()) could the write fail/get delayed?
tstenner
that's what SelectionKey javadoc says.
irreputable