[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with ssh_scp_write() function

I wrote a little test program to copy a file from local to remote host. But I think there is some problem with the ssh_scp_write() function. When I run my program (source code below) without the mssleep() function, only a very small file is created and the the programm exit without a error. With the mssleep() function all things work correctly and the file is copied complete.

Any idea what I'm doing wrong?

/// Test program
First I do the basic stuff like authentication, init new scp session, open local file to read and get local file size, etc...
Then I do (reduced source code):

ssh_scp_push_directoryssh_scp_push_directory(scp, ".", S_IRWXU);
ssh_scp_push_file(scp, "testFile.zip", localSize, S_IRUSR | S_IWUSR);

while (remoteSize != localSize)
        count = fread(buffer, 1, sizeof(buffer), localFile);

        if (ssh_scp_write(scp, buffer, count) != SSH_OK)
            qDebug() << "[ERROR] SshConnect::writeScpData: write error";
            return -1;

        msleep(20);   // it don't works correct without that
        remoteSize += count;

Thanks in advance,

Fix for ssh_scp_write issueEinar Fløystad Dørum <einarfd@xxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org