int hstcpcli::request_send() { if (error_code < 0) { return error_code; } clear_error(); if (fd.get() < 0) { close(); return set_error(-1, "write: closed"); } if (num_req_bufd == 0 || num_req_sent > 0 || num_req_rcvd > 0) { close(); return set_error(-1, "request_send: protocol out of sync"); } const size_t wrlen = writebuf.size(); const ssize_t r = send(fd.get(), writebuf.begin(), wrlen, MSG_NOSIGNAL); if (r <= 0) { close(); return set_error(-1, r < 0 ? "write: failed" : "write: eof"); } writebuf.erase_front(r); if (static_cast<size_t>(r) != wrlen) { close(); return set_error(-1, "write: incomplete"); } num_req_sent = num_req_bufd; num_req_bufd = 0; DBG(fprintf(stderr, "REQSEND 0\n")); return 0; }
void hstcpcli::request_reset() { if (num_req_bufd) { writebuf.erase_front(writebuf.size()); num_req_bufd = 0; } }