void put_pkt(buf_ptr &buf) { assert(buf->head_val() % 4u == 0); sak::const_storage symbol(buf->head(), buf->len()); base::m_coder->set_symbol(base::m_coder->symbols_initialized(), symbol); super::increase_budget(); }
bool write_pkt(buf_ptr &buf) { int len = buf->len(); int res = write(m_fd, buf->head(), buf->len()); if (res == len) return true; if (res > 0) { std::cout << "incomplete write: " << res << std::endl; throw std::runtime_error("incomplete write"); } if (res == 0) return false; if (res < 0 && errno == EAGAIN) return false; throw std::system_error(errno, std::system_category(), "unable to write pkt"); }
bool write_pkt(buf_ptr &buf) { int res = sendto(fd(), buf->head(), buf->len(), 0, sa_send(), sa_send_len()); if (res > 0) { buf->pull(res); return true; } if (res < 0 && (errno == EAGAIN || errno == ENOBUFS)) return false; throw std::system_error(errno, std::system_category(), "unable to write packet"); }