public boolean tryRefer(BufferReferer ref, int len) throws IOException {
        ByteBuffer bb = null;
        try {
            bb = link.getFirst();
        } catch(NoSuchElementException e) {}
        if (bb == null) {
            throw new EndOfBufferException();
        } else if (bb.remaining() < len) {
            return false;
        }
        boolean success = false;
        int pos = bb.position();
        int lim = bb.limit();
        try {
            bb.limit(pos + len);
            ref.refer(bb, true);
            incrReadByteCount(len);
            success = true;
        } finally {
            bb.limit(lim);
            if (success) {
                bb.position(pos + len);
            } else {
                bb.position(pos);
            }
            if (bb.remaining() == 0) {
                removeFirstLink(bb);
            }
        }
        return true;
    }