represents the registration of a
SelectableChannel with a
Selector, and serves to identify a selected
channel and the operations that are ready to be performed on that
channel. After a call to the
method of a selector, the
selectedKeys( ) method of the selector returns a
SelectionKey objects to
identify the channel or channels that are ready for reading, for
writing, or for another operation.
SelectionKey by passing a
Selector object to the
method of a
selector( ) methods of the
SelectionKey return the
objects associated with that key.
When you no longer wish the channel to be registered with the
selector, call the
cancel( ) method of the
determines whether a
SelectionKey is still
cancel( ) method has been called, the
channel has been closed or the selector has been closed.
The main purpose of a
SelectionKey is to hold the
"interest set" of
channel operations that the selector should monitor for the channel,
and also the "ready set" of
operations that the selector has determined are ready to proceed on
the channel. Both sets are represented as integer bitmasks (not
java.util.Set objects) formed by OR-ing together
any of the
OP_ constants defined by this class.
Those constants are the following:
In the interest set, this bit specifies an interest in read operations. ...