예제 #1
0
    void get_pkt(buf_ptr &buf)
    {
        size_t size = base::m_coder->symbol_size();

        memcpy(buf->head(), base::m_coder->symbol(m_decoded++), size);
        buf->trim(size);
        ++m_decoded_count;
    }
예제 #2
0
    bool read_pkt(buf_ptr &buf)
    {
        int res;

        res = read(m_fd, buf->data(), buf->max_len());

        if (res > 0) {
            buf->trim(res);
            return true;
        }

        if (res == 0)
            return false;

        if (res < 0 && errno == EAGAIN)
            return false;

        throw std::system_error(errno, std::system_category(),
                                "unable to read pkt");
    }