Unregister and register again in java NIO -
is possible unregister , register again later on same selector ? have limit amount of connection accept , key.cancel() stop receiving op_accept events.
server.register(selector, selectionkey.op_accept); ... key.cancel() ...
if connection closed, cant run register(..) again, getting java.nio.channels.cancelledkeyexception
javadoc register(..) : throw cancelledkeyexception if channel registered given selector corresponding key has been cancelled
what way achieve trying ?
just clear bits want clear in key's interestops
: example key.interestops(0)
.
Comments
Post a Comment