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

Archive Index This month's Index

Subject: problem with big data packages using libssh2_channel_read

problem with big data packages using libssh2_channel_read

From: Mateusz Pilski <mpilski_at_gmail.com>
Date: Mon, 21 Feb 2011 16:03:11 +0100

Hello there
I'm using libssh2 library to produce ssh client witch is designed for my
clients needs. So far everything was working well, but i discovered that the
program hangs for few seconds on large data packages. For example if in my
program i will send command
cat larg_file.dat
program hangs for few seconds, then it spit out data of maxbuffer size (in
code:HALFBUFFSIZE) then again hangs for few seconds and so on. I'm using
libssh2_channel_read as follows (this is simplified code):

do
{
       libssh2_channel_flush_ex(channel,LIBSSH2_CHANNEL_FLUSH_ALL);
        /*reading*/

        for(i=0;i<BUFFSIZE;i++)schelout[i]=0;
        readlen=libssh2_channel_read(channel,schelout,HALFBUFFSIZE);

if(readlen>0)
{

            if(strlen(schelout)>0)
            printf("%s",schelout);
            fflush(stdout);

}
        c[0]=-1;
        /*writing*/

        mygetch(c); /*this is my function for geting character from keybord
in general it is getc with nonblocking*/

        if(c[0]!=-1)
        {
        libssh2_channel_write(channel,c,strlen(c));
        libssh2_channel_flush(channel);

        }
}while(libssh2_channel_eof(channel)!=1);

looking forward to hearing from you
Mateusz Pilski
p.s. Sorry for my "not ideal" english :)

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-02-21

the libssh2 team