www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: RE: Questions about libssh2_sftp_read()

RE: Questions about libssh2_sftp_read()

From: Nitin Deokate <ndeokate_at_qualys.com>
Date: Tue, 24 Jun 2014 08:37:21 +0530


I have used this test case


I have modified the *char* mem[1024]; to *char* mem[2500];

I am trying to read the 1gb file. First time libssh2_sftp_read()
returns 2000 bytes,

And even in subsequent read calls too.

But last response from Daniel says that I should get bigger chunks in
subsequent call, which

Is not happening. Do I need to change something to get me bigger chunks.



*From:* Nitin Deokate [mailto:ndeokate_at_qualys.com]
*Sent:* Sunday, June 15, 2014 6:05 AM
*To:* Daniel Stenberg
*Cc:* libssh2 development
*Subject:* Re: Questions about libssh2_sftp_read()

Thanks for the reply.
In subsequent reads too, I get smaller chunk.
Could you please suggest what can be done in my code to have more
subsequent calls? any test case you have ?

On Sun, Jun 15, 2014 at 2:34 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:

On Sat, 14 Jun 2014, Nitin Deokate wrote:

1. I have an application, where I use libssh2_sftp_read(), and I pass
larger buffer(say 8K to 16MB) to same function,

What I expect is, data of same bytes, but all I get is 2000Bytes.

No, that is probably all you get in the first read call. That's quite a
difference. In subsequent reads you are likely to get larger pieces.

What could help me to get as equal to the buffer size I passed and not 2000

If you have less latency to the server you may get more, but the first call
is likely to always just give you a small piece.

2. Is it any significant reason for selecting value for

#define MAX_SFTP_READ_SIZE 2000

Why it can’t have more bytes than that?

It can, just bump it. But you will not get the amount you ask for at once,
you can up to that amount, then you call the function over and over again
until you're done.

Has anybody faced this scenario before, please revert as early as possible.

I don't even understand your scenario. We have users downloading insane
amounts of data over SFTP with no problems. This is not a known problem
you're talking about.

The 2K number is simply the "block size". libssh2 sends read MANY requests
with that size and as soon as one comes back it can return data. When you
call read again, more packets might already have arrived and can be
returned and so on. I blogged about this technique when I made this change:


 / daniel.haxx.se

libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2014-06-24

the libssh2 team