I checked the code again, and unfortunately have not found the answer why the block size is limited by 2000 bytes.
libssh2_sftp_read() always returns 2000 if I ask read bigger block. So I had to split reading on several steps with less (fixed) block size. On 26 August 2013 18:13, Velichko Yuriy <[email protected]> wrote: > Thank you for the answer. I'll check my code carefully, to determine i get > such answer from the function. > > > On 23 August 2013 12:58, Daniel Stenberg <[email protected]> wrote: > >> On Fri, 23 Aug 2013, Velichko Yuriy wrote: >> >> I tried to read data from file using function libssh2_sftp_read(3). >>> >>> The buffer_maxlen = 8000 >>> >>> But the "Number of bytes actually populated into buffer" (the return >>> value of function) is always 2000. >>> >> >> I don't think it is always 2000. >> >> When you ask for data with this function from libssh2, the function will >> split up the request into multiple requests for several pieces and as soon >> as the first data has arrived it returns that. The subsequent data pieces >> can then be returned in the next call to this function, should they have >> arrived then. >> >> This is an optimization to help bite off the worst problems with the >> request/response nature of the SFTP protocol and its small packets. You get >> the first data available faster, and chances are that when you subsequently >> ask for more data it might already have been received. >> >> You should still ask for as much data as possible at once so that libssh2 >> will send out requests for all of it, and thus make you get data faster. >> This is especially important if you're on high latency connections. >> >> -- >> >> / daniel.haxx.se >> ______________________________**_________________ >> libssh2-devel http://cool.haxx.se/cgi-bin/** >> mailman/listinfo/libssh2-devel<http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel> >> > > > > -- > Best Regards! > -- Best Regards!
_______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
