I am studying the NIO package. I refer to the NioServer example from here . The selector stream is NioServer.javablocked at
this.selector.select();
Iterator<SelectionKey> selectedKeys = this.selector.selectedKeys().iterator();
while (selectedKeys.hasNext()) {
SelectionKey key = selectedKeys.next();
selectedKeys.remove();
if (!key.isValid()) {
continue;
}
if (key.isAcceptable()) {
this.accept(key);
} else if (key.isReadable()) {
this.read(key);
} else if (key.isWritable()) {
this.write(key);
}
When a remote client connects, the this.accept(key)InterestOps interest is called Read in this method and wakes up the selector. Is this what makes the selector select this channel? So, are we signaling that the channel will be selected?
Now suppose that when writing to a socket channel selector, it is signaled by changing that the channel is ready for recording. But suppose that the recording did not end due to the socket buffer filling, as shown in the code, then we do not change the interest and save it as it is for recording only. then when does the selector select this channel?