Subject: Re: [SFTP] Is there a way to determine the maximum buffer len when reading.

Re: [SFTP] Is there a way to determine the maximum buffer len when reading.

From: Velichko Yuriy <velichko.yuriy_at_gmail.com>
Date: Mon, 26 Aug 2013 18:13:40 +0300

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 <daniel_at_haxx.se> 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!

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2013-08-26