Code example for SelectionKey

Methods: attach, interestOps

0
      if (transport.startConnect()) {
        registerForFirstWrite(key);
      } 
    } 
 
    key.attach(this);
  } 
 
  void registerForFirstWrite(SelectionKey key) throws IOException {
    state = State.WRITING_REQUEST_SIZE;
    key.interestOps(SelectionKey.OP_WRITE);
  } 
 
  protected ByteBuffer getFrameBuffer() {
    return frameBuffer;
  } 
 
  /** 
   * Transition to next state, doing whatever work is required. Since this 
   * method is only called by the selector thread, we can make changes to our 
   * select interests without worrying about concurrency.