Code example for SelectionKey

Methods: attachment, cancel

     * Do connection-close cleanup on a given SelectionKey. 
    private void cleanupSelectionkey(SelectionKey key) {
      // remove the records from the two maps 
      FrameBuffer buffer = (FrameBuffer)key.attachment();
      if (buffer != null) {
        // close the buffer 
      // cancel the selection key 
  } // SelectorThread 
   * Class that implements a sort of state machine around the interaction with 
   * a client and an invoker. It manages reading the frame size and frame data, 
   * getting it handed off as wrapped transports, and then the writing of 
   * reponse data back to the client. In the process it manages flipping the 
   * read and write bits on the selection key for its client.