Code example for SelectionKey

Methods: attach

        client = (TNonblockingTransport)serverTransport.accept();
        clientKey = client.registerSelector(selector, SelectionKey.OP_READ);
        // add this key to the map 
        FrameBuffer frameBuffer = new FrameBuffer(client, clientKey);
      } catch (TTransportException tte) {
        // something went wrong accepting. 
        LOGGER.warn("Exception trying to accept!", tte);
        if (clientKey != null) cleanupSelectionkey(clientKey);
        if (client != null) client.close();
     * Do the work required to read from a readable client. If the frame is 
     * fully read, then invoke the method call. 
    private void handleRead(SelectionKey key) {