static int kftp_send_cmd(knetFile *ftp, const char *cmd, int is_get)
{
if (socket_wait(ftp->ctrl_fd, 0) <= 0) return -1; // socket is not ready for writing
- netwrite(ftp->ctrl_fd, cmd, strlen(cmd));
+ if (netwrite(ftp->ctrl_fd, cmd, strlen(cmd)) < 0) {
+ fprintf(stderr, "[%s] error sending command to socket.\n", __func__);
+ return -1;
+ }
return is_get? kftp_get_response(ftp) : 0;
}
l += sprintf(buf + l, "GET %s HTTP/1.0\r\nHost: %s\r\n", fp->path, fp->http_host);
l += sprintf(buf + l, "Range: bytes=%lld-\r\n", (long long)fp->offset);
l += sprintf(buf + l, "\r\n");
- netwrite(fp->fd, buf, l);
+ if (netwrite(fp->fd, buf, l) < 0) {
+ fprintf(stderr, "[%s] fail write GET line.\n", __func__);
+ return -1;
+ }
l = 0;
while (netread(fp->fd, buf + l, 1)) { // read HTTP header; FIXME: bad efficiency
if (buf[l] == '\n' && l >= 3)