mirror of
https://github.com/libssh2/libssh2.git
synced 2025-07-04 09:22:28 +03:00
examples: fixed and made them more similar
The channel read/write functions can return 0 in legitimate cases without it being an error, and we need to loop properly if they return short.
This commit is contained in:
@ -185,10 +185,13 @@ int main(int argc, char *argv[])
|
||||
do {
|
||||
/* write data in a loop until we block */
|
||||
rc = libssh2_sftp_write(sftp_handle, ptr, nread);
|
||||
if(rc < 0)
|
||||
break;
|
||||
ptr += rc;
|
||||
nread -= nread;
|
||||
} while (rc > 0);
|
||||
} while (1);
|
||||
nread -= rc;
|
||||
} while (nread);
|
||||
|
||||
} while (rc > 0);
|
||||
|
||||
libssh2_sftp_close(sftp_handle);
|
||||
libssh2_sftp_shutdown(sftp_session);
|
||||
|
Reference in New Issue
Block a user