Make libssh2_sftp_write() be fully non-blocking. The state of the socket

is fully honored.  LIBSSH2SFTP_EAGAIN is returned when the call would
block.
This commit is contained in:
James Housley
2007-06-06 19:52:11 +00:00
parent 4b8db8c1ab
commit d141ba49f3
5 changed files with 70 additions and 165 deletions

View File

@@ -1,5 +1,5 @@
/*
* $Id: sftp_RW_nonblock.c,v 1.4 2007/06/06 12:34:08 jehousley Exp $
* $Id: sftp_RW_nonblock.c,v 1.5 2007/06/06 19:52:11 jehousley Exp $
*
* Sample showing how to do SFTP transfers in a non-blocking manner.
*
@@ -241,7 +241,7 @@ int main(int argc, char *argv[])
do {
/* write data in a loop until we block */
rc = libssh2_sftp_writenb(sftp_handle, ptr,
rc = libssh2_sftp_write(sftp_handle, ptr,
nread);
ptr += rc;
nread -= nread;

View File

@@ -1,5 +1,5 @@
/*
* $Id: sftp_write_nonblock.c,v 1.4 2007/06/06 12:34:09 jehousley Exp $
* $Id: sftp_write_nonblock.c,v 1.5 2007/06/06 19:52:11 jehousley Exp $
*
* Sample showing how to do SFTP non-blocking write transfers.
*
@@ -196,7 +196,7 @@ int main(int argc, char *argv[])
do {
/* write data in a loop until we block */
while ((rc = libssh2_sftp_writenb(sftp_handle, ptr, nread)) == LIBSSH2SFTP_EAGAIN) {
while ((rc = libssh2_sftp_write(sftp_handle, ptr, nread)) == LIBSSH2SFTP_EAGAIN) {
;
}
ptr += rc;