problem description
when you look at the ServerBootstrap startup process in Netty, you find that the interestOps registered by NIOServerSocketChannel is 0.
what does it mean to register as 0? shouldn"t ServerSocketChannel register the value of OP_CONNECT (8) or OP_ACCEPT (16)?
how does ServerSocketChannel know about channel establishment and connection?
related codes
@Override
protected void doRegister() throws Exception {
boolean selected = false;
for (;;) {
try {
selectionKey = javaChannel().register(eventLoop().unwrappedSelector(), 0, this);
return;
} catch (CancelledKeyException e) {
if (!selected) {
// Force the Selector to select now as the "canceled" SelectionKey may still be
// cached and not removed because no Select.select(..) operation was called yet.
eventLoop().selectNow();
selected = true;
} else {
// We forced a select operation on the selector before but the SelectionKey is still cached
// for whatever reason. JDK bug ?
throw e;
}
}
}
}
ask God for help, thank you!