Subject: Re: libssh2_sftp_read reads a number of bytes smaller than both the file size and the specified buffer size

Re: libssh2_sftp_read reads a number of bytes smaller than both the file size and the specified buffer size

From: Peter Stuge <peter_at_stuge.se>
Date: Tue, 3 Apr 2012 23:51:33 +0200

Adam Craig wrote:
> > This sounds like the expected behaviour of libssh2's pipelined SFTP
> > architecture. The return value doesn't have to correspond to the
> > amount uploaded on _that_ call as long as the overall total is
> > correct. The last call that doesn't appear to do anything allows
> > libssh2 to do some housekeeping.
>
> What do you mean by the "overall total?"

Number of bytes transfered once libssh2 returns 0 to indicate
completion.

> If I upload a file of 200K all in one call to libssh2_sftp_write and
> it returns 30K when it actually uploaded all 200K, what does the 30K
> return value mean?

It means that libssh2 has sent some data but not all, and you need to
call libssh2 again.

> > I'm not sure why yours are limited to 2K but I believe this is
> > negotiated with the server (jump in here guys if I'm wrong) so
> > it's possible your server is refusing to send bigger packets.

I don't think this is negotiable.

> That was my first guess, and it may be the case. After looking at
> the documentation for the server-side SFTP tool and not finding any
> information about a maximum packet size, I decided to look into
> whether it was an issue with Libssh2.
>
> Documentation I read for the SFTP server utility to which the app
> is connecting:
> http://www.openbsd.org/cgi-bin/man.cgi?query=sftp-server&sektion=8

In any case, OpenSSH sftp-server has pretty much zero tunables.

Is the server OpenBSD, or OpenSSH portable on some other unix?

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2012-04-03