private final void handleSelectedKeys(long now) {
        Iterator<SelectionKey> keys = nioSelector.selectedKeys().iterator();

        while (keys.hasNext()) {
            SelectionKey key = keys.next();
            keys.remove();

            if (key.channel() instanceof ServerSocketChannel) {
                PyroServer server = (PyroServer) key.attachment();
                if (this.listener != null)
                    this.listener.serverSelected(server);
                server.onInterestOp();
            }

            if (key.channel() instanceof SocketChannel) {
                PyroClient client = (PyroClient) key.attachment();
                if (this.listener != null)
                    this.listener.clientSelected(client, key.readyOps());
                client.onInterestOp(now);
            }
        }
    }