From libssh2-devel-bounces@cool.haxx.se  Fri Jan  4 14:38:01 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r04DbWX8027579;
	Fri, 4 Jan 2013 14:37:53 +0100
Received: from mx-out.centralnetpoint.com (mx-out.centralnetpoint.com
 [94.232.196.16])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r04DbVRn027538
 for <libssh2-devel@cool.haxx.se>; Fri, 4 Jan 2013 14:37:31 +0100
Received: from mx-out.centralnetpoint.com (unknown [94.232.196.6])
 by mx-out.centralnetpoint.com (Postfix) with ESMTP id 07A41CA12A
 for <libssh2-devel@cool.haxx.se>; Fri,  4 Jan 2013 14:37:25 +0100 (CET)
Received: from Internal Mail-Server by MX01 (envelope-from
 tyoh@cct-solutions.com) with SMTP; 4 Jan 2013 14:37:26 +0100
Received: from cct-ex.cct.active ([192.168.123.70]) by cct-ex.cct.active
 ([192.168.123.70]) with mapi; Fri, 4 Jan 2013 14:37:24 +0100
From: Ty Oh <tyoh@cct-solutions.com>
To: "libssh2-devel@cool.haxx.se" <libssh2-devel@cool.haxx.se>
Date: Fri, 4 Jan 2013 14:37:24 +0100
Subject: libssh2_channel_read returning different format for same command
Thread-Topic: libssh2_channel_read returning different format for same command
Thread-Index: Ac3qgKBCfIfnI7KPQXyNJsTH4n6OfA==
Message-ID: <8C91ABB802EC89449DA0019B3E44282F6711020F7F@cct-ex.cct.active>
Accept-Language: en-US, de-DE
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
acceptlanguage: en-US, de-DE
MIME-Version: 1.0
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1779460813=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

--===============1779460813==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_8C91ABB802EC89449DA0019B3E44282F6711020F7Fcctexcctactiv_"

--_000_8C91ABB802EC89449DA0019B3E44282F6711020F7Fcctexcctactiv_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi

I am using libssh2_channel_write and libssh2_channel_read to communicate wi=
th a server that accepts commands.
The server returns tab and newline delimited data.

I'm facing a problem where the returned data is not always in the same form=
at for the same command.
e.g. It will have some extra tabs or newlines and sometimes a backspace \x0=
8 etc.

Because, the data is tab and newline delimited, it is impossible to adjust =
and fix the read data.

As far as I can see.

-          The results are random.

-          The first read is always good.

-          Only occurs to large data returned.  E.g. 20k

-          Sometimes it will go wrong on the second time the command was se=
nt, or sometimes on the 17th repeat etc.

I'm certain that this is not a server problem.
I am in the process of porting a released to production application from C#=
 to Ubuntu GCC, and this problem never occurred.

Anyone had such issues?

Here's a snip of the read function.


string SSHManager::ReadResponse(LIBSSH2_CHANNEL *channel)
{
    string r =3D "";

    try
    {
            int bufSize =3D 8192;
        ssize_t readBytes;

        //keep reading until terminator is received. \nt\n
        while (true)
        {
            //new the char array every loop.
            char *buffer =3D new char[bufSize];

            //keep reading
            readBytes =3D libssh2_channel_read(channel, buffer, bufSize);

            if (readBytes < 1)
                return r;
            else if (readBytes =3D=3D 0)
                        return "Error. Socket Closed"; //socket closed.

            if(readBytes < bufSize)
                        buffer[readBytes+1] =3D '\0';

            r.append(buffer);

            delete[] buffer;

            if (r.length() > 2)
            {
                        if(r.find("\nt\n") !=3D string::npos)
                                    break;  //terminator received
            }
        }
    }
    catch (int e)
    {
            ERRORP("An exception occurred. Exception Number %d", e);
    }

    return r;
}




Thanks and Best regards,
Ty



--_000_8C91ABB802EC89449DA0019B3E44282F6711020F7Fcctexcctactiv_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40"><head><meta http-equiv=3DContent-Type content=
=3D"text/html; charset=3Dus-ascii"><meta name=3DGenerator content=3D"Micros=
oft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Malgun Gothic";
	panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:"\@Malgun Gothic";
	panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
	{font-family:Monospace;
	panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{mso-style-priority:34;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:36.0pt;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri","sans-serif";}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
	{page:WordSection1;}
/* List Definitions */
@list l0
	{mso-list-id:280112461;
	mso-list-type:hybrid;
	mso-list-template-ids:2013417362 -1325348268 134807555 134807557 134807553=
 134807555 134807557 134807553 134807555 134807557;}
@list l0:level1
	{mso-level-start-at:5;
	mso-level-number-format:bullet;
	mso-level-text:-;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:"Calibri","sans-serif";
	mso-fareast-font-family:"Malgun Gothic";
	mso-bidi-font-family:"Times New Roman";}
@list l0:level2
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:"Courier New";}
@list l0:level3
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:Wingdings;}
@list l0:level4
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:Symbol;}
@list l0:level5
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:"Courier New";}
@list l0:level6
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:Wingdings;}
@list l0:level7
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:Symbol;}
@list l0:level8
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:"Courier New";}
@list l0:level9
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:Wingdings;}
ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-GB link=3Dblue vli=
nk=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal>Hi <o:p></o:p></=
p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>I am using=
 <b>libssh2_channel_write</b> and <b>libssh2_channel_read</b> to communicat=
e with a server that accepts commands.<o:p></o:p></p><p class=3DMsoNormal>T=
he server returns tab and newline delimited data.<o:p></o:p></p><p class=3D=
MsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>I&#8217;m facing a prob=
lem where the returned data is not always in the same format for the same c=
ommand.<o:p></o:p></p><p class=3DMsoNormal>e.g. It will have some extra tab=
s or newlines and sometimes a backspace \x08 etc.<o:p></o:p></p><p class=3D=
MsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>Because, the data is ta=
b and newline delimited, it is impossible to adjust and fix the read data.<=
o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNorma=
l>As far as I can see.<o:p></o:p></p><p class=3DMsoListParagraph style=3D't=
ext-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span styl=
e=3D'mso-list:Ignore'>-<span style=3D'font:7.0pt "Times New Roman"'>&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]>The=
 results are random.<o:p></o:p></p><p class=3DMsoListParagraph style=3D'tex=
t-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span style=
=3D'mso-list:Ignore'>-<span style=3D'font:7.0pt "Times New Roman"'>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]>The =
first read is always good.<o:p></o:p></p><p class=3DMsoListParagraph style=
=3D'text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span=
 style=3D'mso-list:Ignore'>-<span style=3D'font:7.0pt "Times New Roman"'>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif=
]>Only occurs to large data returned.&nbsp; E.g. 20k<o:p></o:p></p><p class=
=3DMsoListParagraph style=3D'text-indent:-18.0pt;mso-list:l0 level1 lfo1'><=
![if !supportLists]><span style=3D'mso-list:Ignore'>-<span style=3D'font:7.=
0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p; </span></span><![endif]>Sometimes it will go wrong on the second time th=
e command was sent, or sometimes on the 17<sup>th</sup> repeat etc.<o:p></o=
:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>I&#82=
17;m certain that this is not a server problem.<o:p></o:p></p><p class=3DMs=
oNormal>I am in the process of porting a released to production application=
 from C# to Ubuntu GCC, and this problem never occurred. <o:p></o:p></p><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>Anyone had such=
 issues?<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=
=3DMsoNormal>Here&#8217;s a snip of the read function.<o:p></o:p></p><p cla=
ss=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal style=3D'text-auto=
space:none'><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p>&nb=
sp;</o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><spa=
n style=3D'font-size:10.0pt;font-family:Monospace;color:#005032;background:=
silver;mso-highlight:silver'>string</span><span style=3D'font-size:10.0pt;f=
ont-family:Monospace;color:black'> <b>SSHManager::ReadResponse</b>(</span><=
span style=3D'font-size:10.0pt;font-family:Monospace;color:#005032'>LIBSSH2=
_CHANNEL</span><span style=3D'font-size:10.0pt;font-family:Monospace;color:=
black'> *channel)</span><span style=3D'font-size:10.0pt;font-family:Monospa=
ce'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none=
'><span style=3D'font-size:10.0pt;font-family:Monospace;color:black'>{</spa=
n><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span>=
</p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-=
size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp; </span><s=
pan style=3D'font-size:10.0pt;font-family:Monospace;color:#005032;backgroun=
d:silver;mso-highlight:silver'>string</span><span style=3D'font-size:10.0pt=
;font-family:Monospace;color:black'> r =3D </span><span style=3D'font-size:=
10.0pt;font-family:Monospace;color:#2A00FF'>&quot;&quot;</span><span style=
=3D'font-size:10.0pt;font-family:Monospace;color:black'>;</span><span style=
=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=
=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;=
font-family:Monospace'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal sty=
le=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family:Mono=
space;color:black'>&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10=
.0pt;font-family:Monospace;color:#7F0055'>try</span></b><span style=3D'font=
-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNor=
mal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-fami=
ly:Monospace;color:black'>&nbsp;&nbsp;&nbsp; {</span><span style=3D'font-si=
ze:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal=
 style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family:=
Monospace;color:black'>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-family:Monospace;c=
olor:#7F0055'>int</span></b><span style=3D'font-size:10.0pt;font-family:Mon=
ospace;color:black'> bufSize =3D 8192;</span><span style=3D'font-size:10.0p=
t;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal style=
=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family:Monosp=
ace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span st=
yle=3D'font-size:10.0pt;font-family:Monospace;color:#005032'>ssize_t</span>=
<span style=3D'font-size:10.0pt;font-family:Monospace;color:black'> readByt=
es;</span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p=
></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=
=3D'font-size:10.0pt;font-family:Monospace'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10=
.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp; </span><span style=3D'font-size:10.0pt;font-family:Monospace;color:=
#3F7F5F'>//keep reading until terminator is received. \nt\n</span><span sty=
le=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p clas=
s=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt=
;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp; </span><b><span style=3D'font-size:10.0pt;font-family:Monospace;color:#=
7F0055'>while</span></b><span style=3D'font-size:10.0pt;font-family:Monospa=
ce;color:black'> (</span><b><span style=3D'font-size:10.0pt;font-family:Mon=
ospace;color:#7F0055'>true</span></b><span style=3D'font-size:10.0pt;font-f=
amily:Monospace;color:black'>)</span><span style=3D'font-size:10.0pt;font-f=
amily:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-a=
utospace:none'><span style=3D'font-size:10.0pt;font-family:Monospace;color:=
black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><span style=3D'fo=
nt-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoN=
ormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-fa=
mily:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbs=
p;&nbsp;&nbsp; </span><span style=3D'font-size:10.0pt;font-family:Monospace=
;color:#3F7F5F'>//new the char array every loop.</span><span style=3D'font-=
size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNorm=
al style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-famil=
y:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-family:Mono=
space;color:#7F0055'>char</span></b><span style=3D'font-size:10.0pt;font-fa=
mily:Monospace;color:black'> *buffer =3D </span><b><span style=3D'font-size=
:10.0pt;font-family:Monospace;color:#7F0055'>new</span></b><span style=3D'f=
ont-size:10.0pt;font-family:Monospace;color:black'> </span><b><span style=
=3D'font-size:10.0pt;font-family:Monospace;color:#7F0055'>char</span></b><s=
pan style=3D'font-size:10.0pt;font-family:Monospace;color:black'>[bufSize];=
</span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></=
span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'=
font-size:10.0pt;font-family:Monospace'><o:p>&nbsp;</o:p></span></p><p clas=
s=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt=
;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style=3D'font-size:10.0pt;font-fam=
ily:Monospace;color:#3F7F5F'>//keep reading</span><span style=3D'font-size:=
10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal st=
yle=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family:Mon=
ospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=
&nbsp; readBytes =3D libssh2_channel_read(channel, buffer, bufSize);</span>=
<span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></=
p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-si=
ze:10.0pt;font-family:Monospace'><o:p>&nbsp;</o:p></span></p><p class=3DMso=
Normal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-f=
amily:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-family:=
Monospace;color:#7F0055'>if</span></b><span style=3D'font-size:10.0pt;font-=
family:Monospace;color:black'> (readBytes &lt; 1)</span><span style=3D'font=
-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNor=
mal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-fami=
ly:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-siz=
e:10.0pt;font-family:Monospace;color:#7F0055'>return</span></b><span style=
=3D'font-size:10.0pt;font-family:Monospace;color:black'> r;</span><span sty=
le=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p clas=
s=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt=
;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-=
family:Monospace;color:#7F0055'>else</span></b><span style=3D'font-size:10.=
0pt;font-family:Monospace;color:black'> </span><b><span style=3D'font-size:=
10.0pt;font-family:Monospace;color:#7F0055'>if</span></b><span style=3D'fon=
t-size:10.0pt;font-family:Monospace;color:black'> (readBytes =3D=3D 0)</spa=
n><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span>=
</p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-=
size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;fo=
nt-family:Monospace;color:#7F0055'>return</span></b><span style=3D'font-siz=
e:10.0pt;font-family:Monospace;color:black'> </span><span style=3D'font-siz=
e:10.0pt;font-family:Monospace;color:#2A00FF'>&quot;Error. Socket Closed&qu=
ot;</span><span style=3D'font-size:10.0pt;font-family:Monospace;color:black=
'>; </span><span style=3D'font-size:10.0pt;font-family:Monospace;color:#3F7=
F5F'>//socket closed.</span><span style=3D'font-size:10.0pt;font-family:Mon=
ospace'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:=
none'><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p>&nbsp;</o=
:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span styl=
e=3D'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'f=
ont-size:10.0pt;font-family:Monospace;color:#7F0055'>if</span></b><span sty=
le=3D'font-size:10.0pt;font-family:Monospace;color:black'>(readBytes &lt; b=
ufSize)</span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p><=
/o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span st=
yle=3D'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buffer[readBytes+1] =3D </span><=
span style=3D'font-size:10.0pt;font-family:Monospace;color:#2A00FF'>'\0'</s=
pan><span style=3D'font-size:10.0pt;font-family:Monospace;color:black'>;</s=
pan><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></spa=
n></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'fon=
t-size:10.0pt;font-family:Monospace'><o:p>&nbsp;</o:p></span></p><p class=
=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;=
font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp; r.append(buffer);</span><span style=3D'font-size=
:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal s=
tyle=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family:Mo=
nospace'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal style=3D'text-aut=
ospace:none'><span style=3D'font-size:10.0pt;font-family:Monospace;color:bl=
ack'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </s=
pan><b><span style=3D'font-size:10.0pt;font-family:Monospace;color:#7F0055'=
>delete</span></b><span style=3D'font-size:10.0pt;font-family:Monospace;col=
or:black'>[] buffer;</span><span style=3D'font-size:10.0pt;font-family:Mono=
space'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:n=
one'><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p>&nbsp;</o:=
p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=
=3D'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'fo=
nt-size:10.0pt;font-family:Monospace;color:#7F0055'>if</span></b><span styl=
e=3D'font-size:10.0pt;font-family:Monospace;color:black'> (r.length() &gt; =
2)</span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p>=
</span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=
=3D'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><span style=3D'font=
-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNor=
mal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-fami=
ly:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-family:Monospace;c=
olor:#7F0055'>if</span></b><span style=3D'font-size:10.0pt;font-family:Mono=
space;color:black'>(r.find(</span><span style=3D'font-size:10.0pt;font-fami=
ly:Monospace;color:#2A00FF'>&quot;\nt\n&quot;</span><span style=3D'font-siz=
e:10.0pt;font-family:Monospace;color:black'>) !=3D </span><span style=3D'fo=
nt-size:10.0pt;font-family:Monospace;color:#005032;background:silver;mso-hi=
ghlight:silver'>string</span><span style=3D'font-size:10.0pt;font-family:Mo=
nospace;color:black'>::</span><i><span style=3D'font-size:10.0pt;font-famil=
y:Monospace;color:#0000C0'>npos</span></i><span style=3D'font-size:10.0pt;f=
ont-family:Monospace;color:black'>)</span><span style=3D'font-size:10.0pt;f=
ont-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal style=3D't=
ext-autospace:none'><span style=3D'font-size:10.0pt;font-family:Monospace;c=
olor:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>=
<b><span style=3D'font-size:10.0pt;font-family:Monospace;color:#7F0055'>bre=
ak</span></b><span style=3D'font-size:10.0pt;font-family:Monospace;color:bl=
ack'>;&nbsp; </span><span style=3D'font-size:10.0pt;font-family:Monospace;c=
olor:#3F7F5F'>//terminator received</span><span style=3D'font-size:10.0pt;f=
ont-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal style=3D't=
ext-autospace:none'><span style=3D'font-size:10.0pt;font-family:Monospace;c=
olor:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp; }</span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o=
:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span styl=
e=3D'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style=3D'font-size:10.0pt;font-famil=
y:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autos=
pace:none'><span style=3D'font-size:10.0pt;font-family:Monospace;color:blac=
k'>&nbsp;&nbsp;&nbsp; }</span><span style=3D'font-size:10.0pt;font-family:M=
onospace'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospac=
e:none'><span style=3D'font-size:10.0pt;font-family:Monospace;color:black'>=
&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-family:Mo=
nospace;color:#7F0055'>catch</span></b><span style=3D'font-size:10.0pt;font=
-family:Monospace;color:black'> (</span><b><span style=3D'font-size:10.0pt;=
font-family:Monospace;color:#7F0055'>int</span></b><span style=3D'font-size=
:10.0pt;font-family:Monospace;color:black'> e)</span><span style=3D'font-si=
ze:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal=
 style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family:=
Monospace;color:black'>&nbsp;&nbsp;&nbsp; {</span><span style=3D'font-size:=
10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal st=
yle=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family:Mon=
ospace;color:black'>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp; ERRORP(</span><span style=3D'font-size:10.0pt;font-family:Monospace;=
color:#2A00FF'>&quot;An exception occurred. Exception Number %d&quot;</span=
><span style=3D'font-size:10.0pt;font-family:Monospace;color:black'>, e);</=
span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></sp=
an></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'fo=
nt-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp; }</spa=
n><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span>=
</p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-=
size:10.0pt;font-family:Monospace'><o:p>&nbsp;</o:p></span></p><p class=3DM=
soNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font=
-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp; </span><b><span style=3D'=
font-size:10.0pt;font-family:Monospace;color:#7F0055'>return</span></b><spa=
n style=3D'font-size:10.0pt;font-family:Monospace;color:black'> r;</span><s=
pan style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p>=
<p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size=
:10.0pt;font-family:Monospace;color:black'>}</span><span style=3D'font-size=
:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal><=
o:p>&nbsp;</o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMs=
oNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p c=
lass=3DMsoNormal>Thanks and Best regards,<o:p></o:p></p><p class=3DMsoNorma=
l>Ty<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMso=
Normal><o:p>&nbsp;</o:p></p></div></body></html>=

--_000_8C91ABB802EC89449DA0019B3E44282F6711020F7Fcctexcctactiv_--

--===============1779460813==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============1779460813==--

From libssh2-devel-bounces@cool.haxx.se  Fri Jan  4 14:56:37 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r04DuVTQ004638;
	Fri, 4 Jan 2013 14:56:36 +0100
Received: from mx-out.centralnetpoint.com (mx-out.centralnetpoint.com
 [94.232.196.16])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r04DuTof004618
 for <libssh2-devel@cool.haxx.se>; Fri, 4 Jan 2013 14:56:29 +0100
Received: from mx-out.centralnetpoint.com (unknown [94.232.196.9])
 by mx-out.centralnetpoint.com (Postfix) with ESMTP id 0225ECA128
 for <libssh2-devel@cool.haxx.se>; Fri,  4 Jan 2013 14:56:24 +0100 (CET)
Received: from Internal Mail-Server by MX01 (envelope-from
 tyoh@cct-solutions.com) with SMTP; 4 Jan 2013 14:56:21 +0100
Received: from cct-ex.cct.active ([192.168.123.70]) by cct-ex.cct.active
 ([192.168.123.70]) with mapi; Fri, 4 Jan 2013 14:56:17 +0100
From: Ty Oh <tyoh@cct-solutions.com>
To: libssh2 development <libssh2-devel@cool.haxx.se>
Date: Fri, 4 Jan 2013 14:56:16 +0100
Subject: RE: libssh2_channel_read returning different format for same command
Thread-Topic: libssh2_channel_read returning different format for same command
Thread-Index: Ac3qgKBCfIfnI7KPQXyNJsTH4n6OfAAAn5eA
Message-ID: <8C91ABB802EC89449DA0019B3E44282F6711020F80@cct-ex.cct.active>
References: <8C91ABB802EC89449DA0019B3E44282F6711020F7F@cct-ex.cct.active>
In-Reply-To: <8C91ABB802EC89449DA0019B3E44282F6711020F7F@cct-ex.cct.active>
Accept-Language: en-US, de-DE
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
acceptlanguage: en-US, de-DE
MIME-Version: 1.0
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1138503265=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

--===============1138503265==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_8C91ABB802EC89449DA0019B3E44282F6711020F80cctexcctactiv_"

--_000_8C91ABB802EC89449DA0019B3E44282F6711020F80cctexcctactiv_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Oops.  My bad.

I changed the read function and it's fine now.

string ACMManager::ReadOSSIResponse(LIBSSH2_CHANNEL *channel)
{
    string r =3D "";

    try
    {
            int bufSize =3D 8192;
        ssize_t readBytes;

        //keep reading until terminator is received. \nt\n
        while (true)
        {
            //new the char array every loop.
            char *buffer =3D new char[bufSize];

            //keep reading
            readBytes =3D libssh2_channel_read(channel, buffer, (bufSize-1)=
);

            if (readBytes < 1)
                return r;
            else if (readBytes =3D=3D 0)
                        return "Error. Socket Closed"; //socket closed.

           buffer[readBytes] =3D '\0';

            r.append(buffer);

            delete[] buffer;

            if (r.length() > 2)
            {
                        if(r.find("\nt\n") !=3D string::npos)
                                    break;  //terminator received
            }
        }
    }
    catch (int e)
    {
            ERRORP("An exception occurred. Exception Number %d", e);
    }

    return r;
}

From: libssh2-devel [mailto:libssh2-devel-bounces@cool.haxx.se] On Behalf O=
f Ty Oh
Sent: Freitag, 4. Januar 2013 14:37
To: libssh2-devel@cool.haxx.se
Subject: libssh2_channel_read returning different format for same command

Hi

I am using libssh2_channel_write and libssh2_channel_read to communicate wi=
th a server that accepts commands.
The server returns tab and newline delimited data.

I'm facing a problem where the returned data is not always in the same form=
at for the same command.
e.g. It will have some extra tabs or newlines and sometimes a backspace \x0=
8 etc.

Because, the data is tab and newline delimited, it is impossible to adjust =
and fix the read data.

As far as I can see.

-          The results are random.

-          The first read is always good.

-          Only occurs to large data returned.  E.g. 20k

-          Sometimes it will go wrong on the second time the command was se=
nt, or sometimes on the 17th repeat etc.

I'm certain that this is not a server problem.
I am in the process of porting a released to production application from C#=
 to Ubuntu GCC, and this problem never occurred.

Anyone had such issues?

Here's a snip of the read function.


string SSHManager::ReadResponse(LIBSSH2_CHANNEL *channel)
{
    string r =3D "";

    try
    {
            int bufSize =3D 8192;
        ssize_t readBytes;

        //keep reading until terminator is received. \nt\n
        while (true)
        {
            //new the char array every loop.
            char *buffer =3D new char[bufSize];

            //keep reading
            readBytes =3D libssh2_channel_read(channel, buffer, bufSize);

            if (readBytes < 1)
                return r;
            else if (readBytes =3D=3D 0)
                        return "Error. Socket Closed"; //socket closed.

            if(readBytes < bufSize)
                        buffer[readBytes+1] =3D '\0';

            r.append(buffer);

            delete[] buffer;

            if (r.length() > 2)
            {
                        if(r.find("\nt\n") !=3D string::npos)
                                    break;  //terminator received
            }
        }
    }
    catch (int e)
    {
            ERRORP("An exception occurred. Exception Number %d", e);
    }

    return r;
}




Thanks and Best regards,
Ty



--_000_8C91ABB802EC89449DA0019B3E44282F6711020F80cctexcctactiv_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV=3D"Content-Type" CONTENT=
=3D"text/html; charset=3Dus-ascii"><meta name=3DGenerator content=3D"Micros=
oft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Malgun Gothic";
	panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:"\@Malgun Gothic";
	panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
	{font-family:Monospace;
	panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{mso-style-priority:34;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:36.0pt;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
span.EmailStyle18
	{mso-style-type:personal;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
span.EmailStyle19
	{mso-style-type:personal-reply;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
	{page:WordSection1;}
/* List Definitions */
@list l0
	{mso-list-id:280112461;
	mso-list-type:hybrid;
	mso-list-template-ids:2013417362 -1325348268 134807555 134807557 134807553=
 134807555 134807557 134807553 134807555 134807557;}
@list l0:level1
	{mso-level-start-at:5;
	mso-level-number-format:bullet;
	mso-level-text:-;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:"Calibri","sans-serif";
	mso-fareast-font-family:"Malgun Gothic";
	mso-bidi-font-family:"Times New Roman";}
@list l0:level2
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:"Courier New";}
@list l0:level3
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:Wingdings;}
@list l0:level4
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:Symbol;}
@list l0:level5
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:"Courier New";}
@list l0:level6
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:Wingdings;}
@list l0:level7
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:Symbol;}
@list l0:level8
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:"Courier New";}
@list l0:level9
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:Wingdings;}
ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-GB link=3Dblue vli=
nk=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal><span style=3D'c=
olor:#1F497D'>Oops.&nbsp; My bad.<o:p></o:p></span></p><p class=3DMsoNormal=
><span style=3D'color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNo=
rmal><span style=3D'color:#1F497D'>I changed the read function and it&#8217=
;s fine now.<o:p></o:p></span></p><p class=3DMsoNormal><span style=3D'color=
:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal style=3D'text-au=
tospace:none'><span style=3D'font-size:10.0pt;font-family:Monospace;color:#=
005032'>string</span><span style=3D'font-size:10.0pt;font-family:Monospace;=
color:black'> <b>ACMManager::ReadOSSIResponse</b>(</span><span style=3D'fon=
t-size:10.0pt;font-family:Monospace;color:#005032'>LIBSSH2_CHANNEL</span><s=
pan style=3D'font-size:10.0pt;font-family:Monospace;color:black'> *channel)=
</span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></=
span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'=
font-size:10.0pt;font-family:Monospace;color:black'>{</span><span style=3D'=
font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMs=
oNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-=
family:Monospace;color:black'>&nbsp;&nbsp;&nbsp; </span><span style=3D'font=
-size:10.0pt;font-family:Monospace;color:#005032'>string</span><span style=
=3D'font-size:10.0pt;font-family:Monospace;color:black'> r =3D </span><span=
 style=3D'font-size:10.0pt;font-family:Monospace;color:#2A00FF'>&quot;&quot=
;</span><span style=3D'font-size:10.0pt;font-family:Monospace;color:black'>=
;</span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p><=
/span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D=
'font-size:10.0pt;font-family:Monospace'><o:p>&nbsp;</o:p></span></p><p cla=
ss=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0p=
t;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp; </span><b><span sty=
le=3D'font-size:10.0pt;font-family:Monospace;color:#7F0055'>try</span></b><=
span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p=
><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-siz=
e:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp; {</span><spa=
n style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p=
 class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:1=
0.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-=
family:Monospace;color:#7F0055'>int</span></b><span style=3D'font-size:10.0=
pt;font-family:Monospace;color:black'> bufSize =3D 8192;</span><span style=
=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=
=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;=
font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p; </span><span style=3D'font-size:10.0pt;font-family:Monospace;color:#0050=
32'>ssize_t</span><span style=3D'font-size:10.0pt;font-family:Monospace;col=
or:black'> readBytes;</span><span style=3D'font-size:10.0pt;font-family:Mon=
ospace'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:=
none'><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p>&nbsp;</o=
:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span styl=
e=3D'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp; </span><span style=3D'font-size:10.0pt;font-family=
:Monospace;color:#3F7F5F'>//keep reading until terminator is received. \nt\=
n</span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p><=
/span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D=
'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-family:=
Monospace;color:#7F0055'>while</span></b><span style=3D'font-size:10.0pt;fo=
nt-family:Monospace;color:black'> (</span><b><span style=3D'font-size:10.0p=
t;font-family:Monospace;color:#7F0055'>true</span></b><span style=3D'font-s=
ize:10.0pt;font-family:Monospace;color:black'>)</span><span style=3D'font-s=
ize:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNorma=
l style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family=
:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span>=
<span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></=
p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-si=
ze:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style=3D'font-size:10.0pt;font=
-family:Monospace;color:#3F7F5F'>//new the char array every loop.</span><sp=
an style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><=
p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:=
10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt=
;font-family:Monospace;color:#7F0055'>char</span></b><span style=3D'font-si=
ze:10.0pt;font-family:Monospace;color:black'> *buffer =3D </span><b><span s=
tyle=3D'font-size:10.0pt;font-family:Monospace;color:#7F0055'>new</span></b=
><span style=3D'font-size:10.0pt;font-family:Monospace;color:black'> </span=
><b><span style=3D'font-size:10.0pt;font-family:Monospace;color:#7F0055'>ch=
ar</span></b><span style=3D'font-size:10.0pt;font-family:Monospace;color:bl=
ack'>[bufSize];</span><span style=3D'font-size:10.0pt;font-family:Monospace=
'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'>=
<span style=3D'font-size:10.0pt;font-family:Monospace'><o:p>&nbsp;</o:p></s=
pan></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'f=
ont-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style=3D'font-size:=
10.0pt;font-family:Monospace;color:#3F7F5F'>//keep reading</span><span styl=
e=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=
=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;=
font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p; &nbsp;&nbsp;&nbsp; readBytes =3D <span style=3D'background:silver;mso-hi=
ghlight:silver'>libssh2_channel_read</span>(channel, buffer, (bufSize-1));<=
/span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></s=
pan></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'f=
ont-size:10.0pt;font-family:Monospace'><o:p>&nbsp;</o:p></span></p><p class=
=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;=
font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-f=
amily:Monospace;color:#7F0055'>if</span></b><span style=3D'font-size:10.0pt=
;font-family:Monospace;color:black'> (readBytes &lt; 1)</span><span style=
=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=
=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;=
font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><b><span style=3D=
'font-size:10.0pt;font-family:Monospace;color:#7F0055'>return</span></b><sp=
an style=3D'font-size:10.0pt;font-family:Monospace;color:black'> r;</span><=
span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p=
><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-siz=
e:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0=
pt;font-family:Monospace;color:#7F0055'>else</span></b><span style=3D'font-=
size:10.0pt;font-family:Monospace;color:black'> </span><b><span style=3D'fo=
nt-size:10.0pt;font-family:Monospace;color:#7F0055'>if</span></b><span styl=
e=3D'font-size:10.0pt;font-family:Monospace;color:black'> (readBytes =3D=3D=
 0)</span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p=
></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=
=3D'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:=
10.0pt;font-family:Monospace;color:#7F0055'>return</span></b><span style=3D=
'font-size:10.0pt;font-family:Monospace;color:black'> </span><span style=3D=
'font-size:10.0pt;font-family:Monospace;color:#2A00FF'>&quot;Error. Socket =
Closed&quot;</span><span style=3D'font-size:10.0pt;font-family:Monospace;co=
lor:black'>; </span><span style=3D'font-size:10.0pt;font-family:Monospace;c=
olor:#3F7F5F'>//socket closed.</span><span style=3D'font-size:10.0pt;font-f=
amily:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-a=
utospace:none'><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p>=
&nbsp;</o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><=
span style=3D'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  buffer[readBytes] =3D =
</span><span style=3D'font-size:10.0pt;font-family:Monospace;color:#2A00FF'=
>'\0'</span><span style=3D'font-size:10.0pt;font-family:Monospace;color:bla=
ck'>;</span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o=
:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span styl=
e=3D'font-size:10.0pt;font-family:Monospace;color:black'><o:p>&nbsp;</o:p><=
/span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D=
'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r.append(buffer);</span><span =
style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p c=
lass=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.=
0pt;font-family:Monospace'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal=
 style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family:=
Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-family:Monosp=
ace;color:#7F0055'>delete</span></b><span style=3D'font-size:10.0pt;font-fa=
mily:Monospace;color:black'>[] buffer;</span><span style=3D'font-size:10.0p=
t;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal style=
=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family:Monosp=
ace'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal style=3D'text-autospa=
ce:none'><span style=3D'font-size:10.0pt;font-family:Monospace;color:black'=
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>=
<b><span style=3D'font-size:10.0pt;font-family:Monospace;color:#7F0055'>if<=
/span></b><span style=3D'font-size:10.0pt;font-family:Monospace;color:black=
'> (r.length() &gt; 2)</span><span style=3D'font-size:10.0pt;font-family:Mo=
nospace'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace=
:none'><span style=3D'font-size:10.0pt;font-family:Monospace;color:black'>&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><=
span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p=
><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-siz=
e:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-=
family:Monospace;color:#7F0055'>if</span></b><span style=3D'font-size:10.0p=
t;font-family:Monospace;color:black'>(r.find(</span><span style=3D'font-siz=
e:10.0pt;font-family:Monospace;color:#2A00FF'>&quot;\nt\n&quot;</span><span=
 style=3D'font-size:10.0pt;font-family:Monospace;color:black'>) !=3D </span=
><span style=3D'font-size:10.0pt;font-family:Monospace;color:#005032'>strin=
g</span><span style=3D'font-size:10.0pt;font-family:Monospace;color:black'>=
::</span><i><span style=3D'font-size:10.0pt;font-family:Monospace;color:#00=
00C0'>npos</span></i><span style=3D'font-size:10.0pt;font-family:Monospace;=
color:black'>)</span><span style=3D'font-size:10.0pt;font-family:Monospace'=
><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><=
span style=3D'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'fon=
t-size:10.0pt;font-family:Monospace;color:#7F0055'>break</span></b><span st=
yle=3D'font-size:10.0pt;font-family:Monospace;color:black'>;&nbsp; </span><=
span style=3D'font-size:10.0pt;font-family:Monospace;color:#3F7F5F'>//termi=
nator received</span><span style=3D'font-size:10.0pt;font-family:Monospace'=
><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><=
span style=3D'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span sty=
le=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p clas=
s=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt=
;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp; }</span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o=
:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span styl=
e=3D'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp;=
 }</span><span style=3D'font-size:10.0pt;font-family:Monospace'><o:p></o:p>=
</span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=
=3D'font-size:10.0pt;font-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp; =
</span><b><span style=3D'font-size:10.0pt;font-family:Monospace;color:#7F00=
55'>catch</span></b><span style=3D'font-size:10.0pt;font-family:Monospace;c=
olor:black'> (</span><b><span style=3D'font-size:10.0pt;font-family:Monospa=
ce;color:#7F0055'>int</span></b><span style=3D'font-size:10.0pt;font-family=
:Monospace;color:black'> e)</span><span style=3D'font-size:10.0pt;font-fami=
ly:Monospace'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-auto=
space:none'><span style=3D'font-size:10.0pt;font-family:Monospace;color:bla=
ck'>&nbsp;&nbsp;&nbsp; {</span><span style=3D'font-size:10.0pt;font-family:=
Monospace'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospa=
ce:none'><span style=3D'font-size:10.0pt;font-family:Monospace;color:black'=
>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ERRORP(</spa=
n><span style=3D'font-size:10.0pt;font-family:Monospace;color:#2A00FF'>&quo=
t;An exception occurred. Exception Number %d&quot;</span><span style=3D'fon=
t-size:10.0pt;font-family:Monospace;color:black'>, e);</span><span style=3D=
'font-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DM=
soNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font=
-family:Monospace;color:black'>&nbsp;&nbsp;&nbsp; }</span><span style=3D'fo=
nt-size:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoN=
ormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-fa=
mily:Monospace'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal style=3D't=
ext-autospace:none'><span style=3D'font-size:10.0pt;font-family:Monospace;c=
olor:black'>&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;fo=
nt-family:Monospace;color:#7F0055'>return</span></b><span style=3D'font-siz=
e:10.0pt;font-family:Monospace;color:black'> r;</span><span style=3D'font-s=
ize:10.0pt;font-family:Monospace'><o:p></o:p></span></p><p class=3DMsoNorma=
l><span style=3D'font-size:10.0pt;font-family:Monospace;color:black'>}</spa=
n><span style=3D'color:#1F497D'><o:p></o:p></span></p><p class=3DMsoNormal>=
<span style=3D'color:#1F497D'><o:p>&nbsp;</o:p></span></p><div><div style=
=3D'border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><=
p class=3DMsoNormal><b><span lang=3DEN-US style=3D'font-size:10.0pt;font-fa=
mily:"Tahoma","sans-serif"'>From:</span></b><span lang=3DEN-US style=3D'fon=
t-size:10.0pt;font-family:"Tahoma","sans-serif"'> libssh2-devel [mailto:lib=
ssh2-devel-bounces@cool.haxx.se] <b>On Behalf Of </b>Ty Oh<br><b>Sent:</b> =
Freitag, 4. Januar 2013 14:37<br><b>To:</b> libssh2-devel@cool.haxx.se<br><=
b>Subject:</b> libssh2_channel_read returning different format for same com=
mand<o:p></o:p></span></p></div></div><p class=3DMsoNormal><o:p>&nbsp;</o:p=
></p><p class=3DMsoNormal>Hi <o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp=
;</o:p></p><p class=3DMsoNormal>I am using <b>libssh2_channel_write</b> and=
 <b>libssh2_channel_read</b> to communicate with a server that accepts comm=
ands.<o:p></o:p></p><p class=3DMsoNormal>The server returns tab and newline=
 delimited data.<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p=
 class=3DMsoNormal>I&#8217;m facing a problem where the returned data is no=
t always in the same format for the same command.<o:p></o:p></p><p class=3D=
MsoNormal>e.g. It will have some extra tabs or newlines and sometimes a bac=
kspace \x08 etc.<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p=
 class=3DMsoNormal>Because, the data is tab and newline delimited, it is im=
possible to adjust and fix the read data.<o:p></o:p></p><p class=3DMsoNorma=
l><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>As far as I can see.<o:p></o:p>=
</p><p class=3DMsoListParagraph style=3D'text-indent:-18.0pt;mso-list:l0 le=
vel1 lfo2'><![if !supportLists]><span style=3D'mso-list:Ignore'>-<span styl=
e=3D'font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp; </span></span><![endif]>The results are random.<o:p></o:p></=
p><p class=3DMsoListParagraph style=3D'text-indent:-18.0pt;mso-list:l0 leve=
l1 lfo2'><![if !supportLists]><span style=3D'mso-list:Ignore'>-<span style=
=3D'font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; </span></span><![endif]>The first read is always good.<o:p></=
o:p></p><p class=3DMsoListParagraph style=3D'text-indent:-18.0pt;mso-list:l=
0 level1 lfo2'><![if !supportLists]><span style=3D'mso-list:Ignore'>-<span =
style=3D'font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp; </span></span><![endif]>Only occurs to large data return=
ed.&nbsp; E.g. 20k<o:p></o:p></p><p class=3DMsoListParagraph style=3D'text-=
indent:-18.0pt;mso-list:l0 level1 lfo2'><![if !supportLists]><span style=3D=
'mso-list:Ignore'>-<span style=3D'font:7.0pt "Times New Roman"'>&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]>Sometim=
es it will go wrong on the second time the command was sent, or sometimes o=
n the 17<sup>th</sup> repeat etc.<o:p></o:p></p><p class=3DMsoNormal><o:p>&=
nbsp;</o:p></p><p class=3DMsoNormal>I&#8217;m certain that this is not a se=
rver problem.<o:p></o:p></p><p class=3DMsoNormal>I am in the process of por=
ting a released to production application from C# to Ubuntu GCC, and this p=
roblem never occurred. <o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p=
></p><p class=3DMsoNormal>Anyone had such issues?<o:p></o:p></p><p class=3D=
MsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>Here&#8217;s a snip of =
the read function.<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p>=
<p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size=
:10.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p><p class=3DM=
soNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font=
-family:"Courier New";color:#005032;background:silver;mso-highlight:silver'=
>string</span><span style=3D'font-size:10.0pt;font-family:"Courier New";col=
or:black'> <b>SSHManager::ReadResponse</b>(</span><span style=3D'font-size:=
10.0pt;font-family:"Courier New";color:#005032'>LIBSSH2_CHANNEL</span><span=
 style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> *channel=
)</span><span style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o=
:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span styl=
e=3D'font-size:10.0pt;font-family:"Courier New";color:black'>{</span><span =
style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>=
<p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size=
:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp; </span><s=
pan style=3D'font-size:10.0pt;font-family:"Courier New";color:#005032;backg=
round:silver;mso-highlight:silver'>string</span><span style=3D'font-size:10=
.0pt;font-family:"Courier New";color:black'> r =3D </span><span style=3D'fo=
nt-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;&quot;</span>=
<span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>;</s=
pan><span style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p><=
/span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D=
'font-size:10.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p><p=
 class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:1=
0.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp; </span><b><=
span style=3D'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>try=
</span></b><span style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p>=
</o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span s=
tyle=3D'font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp=
;&nbsp; {</span><span style=3D'font-size:10.0pt;font-family:"Courier New"'>=
<o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><s=
pan style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;=
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span sty=
le=3D'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>int</span><=
/b><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> =
bufSize =3D 8192;</span><span style=3D'font-size:10.0pt;font-family:"Courie=
r New"'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:=
none'><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black=
'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style=3D'font-siz=
e:10.0pt;font-family:"Courier New";color:#005032'>ssize_t</span><span style=
=3D'font-size:10.0pt;font-family:"Courier New";color:black'> readBytes;</sp=
an><span style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></=
span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'=
font-size:10.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10=
.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp; </span><span style=3D'font-size:10.0pt;font-family:"Courier New=
";color:#3F7F5F'>//keep reading until terminator is received. \nt\n</span><=
span style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span=
></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font=
-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-family:"=
Courier New";color:#7F0055'>while</span></b><span style=3D'font-size:10.0pt=
;font-family:"Courier New";color:black'> (</span><b><span style=3D'font-siz=
e:10.0pt;font-family:"Courier New";color:#7F0055'>true</span></b><span styl=
e=3D'font-size:10.0pt;font-family:"Courier New";color:black'>)</span><span =
style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>=
<p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size=
:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp; {</span><span style=3D'font-size:10.0pt;font-family:"Courier=
 New"'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:n=
one'><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'=
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span=
 style=3D'font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'>//new t=
he char array every loop.</span><span style=3D'font-size:10.0pt;font-family=
:"Courier New"'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-au=
tospace:none'><span style=3D'font-size:10.0pt;font-family:"Courier New";col=
or:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
; </span><b><span style=3D'font-size:10.0pt;font-family:"Courier New";color=
:#7F0055'>char</span></b><span style=3D'font-size:10.0pt;font-family:"Couri=
er New";color:black'> *buffer =3D </span><b><span style=3D'font-size:10.0pt=
;font-family:"Courier New";color:#7F0055'>new</span></b><span style=3D'font=
-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style=
=3D'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>char</span></=
b><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>[b=
ufSize];</span><span style=3D'font-size:10.0pt;font-family:"Courier New"'><=
o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><sp=
an style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></=
span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'=
font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style=3D'font-=
size:10.0pt;font-family:"Courier New";color:#3F7F5F'>//keep reading</span><=
span style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span=
></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font=
-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; readBytes =3D libssh2_channel_read(c=
hannel, buffer, bufSize);</span><span style=3D'font-size:10.0pt;font-family=
:"Courier New"'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-au=
tospace:none'><span style=3D'font-size:10.0pt;font-family:"Courier New"'><o=
:p>&nbsp;</o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none=
'><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b>=
<span style=3D'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>if=
</span></b><span style=3D'font-size:10.0pt;font-family:"Courier New";color:=
black'> (readBytes &lt; 1)</span><span style=3D'font-size:10.0pt;font-famil=
y:"Courier New"'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-a=
utospace:none'><span style=3D'font-size:10.0pt;font-family:"Courier New";co=
lor:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-f=
amily:"Courier New";color:#7F0055'>return</span></b><span style=3D'font-siz=
e:10.0pt;font-family:"Courier New";color:black'> r;</span><span style=3D'fo=
nt-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=3D=
MsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;fon=
t-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-=
family:"Courier New";color:#7F0055'>else</span></b><span style=3D'font-size=
:10.0pt;font-family:"Courier New";color:black'> </span><b><span style=3D'fo=
nt-size:10.0pt;font-family:"Courier New";color:#7F0055'>if</span></b><span =
style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> (readByte=
s =3D=3D 0)</span><span style=3D'font-size:10.0pt;font-family:"Courier New"=
'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'>=
<span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span styl=
e=3D'font-size:10.0pt;font-family:"Courier New";color:#7F0055'>return</span=
></b><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'=
> </span><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#2=
A00FF'>&quot;Error. Socket Closed&quot;</span><span style=3D'font-size:10.0=
pt;font-family:"Courier New";color:black'>; </span><span style=3D'font-size=
:10.0pt;font-family:"Courier New";color:#3F7F5F'>//socket closed.</span><sp=
an style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span><=
/p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-s=
ize:10.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p><p class=
=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;=
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;fo=
nt-family:"Courier New";color:#7F0055'>if</span></b><span style=3D'font-siz=
e:10.0pt;font-family:"Courier New";color:black'>(readBytes &lt; bufSize)</s=
pan><span style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p><=
/span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D=
'font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buffer[readBytes+1] =3D </span><sp=
an style=3D'font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>'\0'<=
/span><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black=
'>;</span><span style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p><=
/o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span st=
yle=3D'font-size:10.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span>=
</p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-=
size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r.append(buffer);</span><span st=
yle=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p=
 class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:1=
0.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p><p class=3DMso=
Normal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-f=
amily:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-fam=
ily:"Courier New";color:#7F0055'>delete</span></b><span style=3D'font-size:=
10.0pt;font-family:"Courier New";color:black'>[] buffer;</span><span style=
=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p cl=
ass=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10.0=
pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNor=
mal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-fami=
ly:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-family=
:"Courier New";color:#7F0055'>if</span></b><span style=3D'font-size:10.0pt;=
font-family:"Courier New";color:black'> (r.length() &gt; 2)</span><span sty=
le=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p =
class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:10=
.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><span style=3D'font-size:10.0pt=
;font-family:"Courier New"'><o:p></o:p></span></p><p class=3DMsoNormal styl=
e=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family:"Cour=
ier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp; </span><b><span style=3D'font-size:10.0pt;font-family:"Courier New";c=
olor:#7F0055'>if</span></b><span style=3D'font-size:10.0pt;font-family:"Cou=
rier New";color:black'>(r.find(</span><span style=3D'font-size:10.0pt;font-=
family:"Courier New";color:#2A00FF'>&quot;\nt\n&quot;</span><span style=3D'=
font-size:10.0pt;font-family:"Courier New";color:black'>) !=3D </span><span=
 style=3D'font-size:10.0pt;font-family:"Courier New";color:#005032;backgrou=
nd:silver;mso-highlight:silver'>string</span><span style=3D'font-size:10.0p=
t;font-family:"Courier New";color:black'>::</span><i><span style=3D'font-si=
ze:10.0pt;font-family:"Courier New";color:#0000C0'>npos</span></i><span sty=
le=3D'font-size:10.0pt;font-family:"Courier New";color:black'>)</span><span=
 style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p=
><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-siz=
e:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font=
-family:"Courier New";color:#7F0055'>break</span></b><span style=3D'font-si=
ze:10.0pt;font-family:"Courier New";color:black'>;&nbsp; </span><span style=
=3D'font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'>//terminator =
received</span><span style=3D'font-size:10.0pt;font-family:"Courier New"'><=
o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><sp=
an style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span s=
tyle=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><=
p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-size:=
10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; }</span><span style=3D'font-size:10.0pt;font-family:"Courier =
New"'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospace:no=
ne'><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>=
&nbsp;&nbsp;&nbsp; }</span><span style=3D'font-size:10.0pt;font-family:"Cou=
rier New"'><o:p></o:p></span></p><p class=3DMsoNormal style=3D'text-autospa=
ce:none'><span style=3D'font-size:10.0pt;font-family:"Courier New";color:bl=
ack'>&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:10.0pt;font-fami=
ly:"Courier New";color:#7F0055'>catch</span></b><span style=3D'font-size:10=
.0pt;font-family:"Courier New";color:black'> (</span><b><span style=3D'font=
-size:10.0pt;font-family:"Courier New";color:#7F0055'>int</span></b><span s=
tyle=3D'font-size:10.0pt;font-family:"Courier New";color:black'> e)</span><=
span style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span=
></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font=
-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp; {</s=
pan><span style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p><=
/span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D=
'font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ERRORP(</span><span style=3D'fo=
nt-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;An exception =
occurred. Exception Number %d&quot;</span><span style=3D'font-size:10.0pt;f=
ont-family:"Courier New";color:black'>, e);</span><span style=3D'font-size:=
10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=3DMsoNorma=
l style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family=
:"Courier New";color:black'>&nbsp;&nbsp;&nbsp; }</span><span style=3D'font-=
size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=3DMso=
Normal style=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-f=
amily:"Courier New"'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal style=
=3D'text-autospace:none'><span style=3D'font-size:10.0pt;font-family:"Couri=
er New";color:black'>&nbsp;&nbsp;&nbsp; </span><b><span style=3D'font-size:=
10.0pt;font-family:"Courier New";color:#7F0055'>return</span></b><span styl=
e=3D'font-size:10.0pt;font-family:"Courier New";color:black'> r;</span><spa=
n style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></=
p><p class=3DMsoNormal style=3D'text-autospace:none'><span style=3D'font-si=
ze:10.0pt;font-family:"Courier New";color:black'>}</span><span style=3D'fon=
t-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=3DM=
soNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:=
p></p><p class=3DMsoNormal>Thanks and Best regards,<o:p></o:p></p><p class=
=3DMsoNormal>Ty<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p></div></body></html>=

--_000_8C91ABB802EC89449DA0019B3E44282F6711020F80cctexcctactiv_--

--===============1138503265==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============1138503265==--

From libssh2-devel-bounces@cool.haxx.se  Tue Jan  8 01:31:21 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r080UqAc008978;
	Tue, 8 Jan 2013 01:31:15 +0100
Received: from earth.stuge.se (earth.stuge.se [212.116.89.126])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r080UpZW008970
 for <libssh2-devel@cool.haxx.se>; Tue, 8 Jan 2013 01:30:51 +0100
Received: (qmail 5867 invoked from network); 8 Jan 2013 00:30:49 -0000
Received: from unknown (HELO earth.stuge.se) (127.0.0.1)
 by localhost with SMTP; 8 Jan 2013 00:30:49 -0000
MIME-Version: 1.0
From: "libssh2 Trac" <trac@libssh2.stuge.se>
X-Trac-Version: 1.0dev
Precedence: bulk
Cc: libssh2-devel@cool.haxx.se
Auto-Submitted: auto-generated
X-Mailer: Trac 1.0dev, by Edgewall Software
X-Trac-Project: libssh2
Date: Tue, 08 Jan 2013 00:30:49 -0000
X-URL: https://trac.libssh2.org/
Subject: [libssh2] #254: keepalive + blocking scp = LIBSSH2_ERROR_BAD_USE
X-Trac-Ticket-URL: https://trac.libssh2.org/ticket/254
Message-ID: <044.ecd860aab6d87c9fd17e635cc2659abe@libssh2.stuge.se>
X-Trac-Ticket-ID: 254
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id r080UpZW008970
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Reply-To: trac@libssh2.stuge.se,
        libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

#254: keepalive + blocking scp = LIBSSH2_ERROR_BAD_USE
---------------------+--------------------
 Reporter:  ArtemGr  |       Owner:
     Type:  defect   |      Status:  new
 Priority:  normal   |   Milestone:  1.4.3
Component:  SCP      |     Version:  1.4.2
 Keywords:           |  Blocked By:
   Blocks:           |
---------------------+--------------------
 I'm seeing LIBSSH2_ERROR_BAD_USE from blocking libssh2_channel_write_ex
 when keepalive is enabled with libssh2_keepalive_config.

 Source: https://gist.github.com/4364070
 LIBSSH2_ERROR_BAD_USE happens on line 362 if keepalive is turned on at
 line 305. (Enabling or commenting out the libssh2_keepalive_send on line
 265 makes no difference).

-- 
Ticket URL: <https://trac.libssh2.org/ticket/254>
libssh2 <https://trac.libssh2.org/>
C library for writing portable SSH2 clients

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Tue Jan 15 15:56:18 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0FEthYV021061;
	Tue, 15 Jan 2013 15:56:09 +0100
Received: from mail-qa0-f44.google.com (mail-qa0-f44.google.com
 [209.85.216.44])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0FEte9s021003
 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Tue, 15 Jan 2013 15:55:41 +0100
Received: by mail-qa0-f44.google.com with SMTP id z4so2424198qan.17
 for <libssh2-devel@cool.haxx.se>; Tue, 15 Jan 2013 06:55:34 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:date:message-id:subject:from:to:content-type;
 bh=iL7BteFLfMs7tNSlw2mpD2QagjSr7jg2MX8J+Qcmj+M=;
 b=ZRdJ50/1EQBE3b8K48MddN1uwNvgxvtT47acQu4iaEWp2xxhWrq4q7OLuyJBKk8XGK
 vXKYzf5PQAafvHuQhzIn6q043FMk+Qx+7icTOCa2/JfiswXYYPlWrjWs+e9VIyzlJxe6
 W43wgraY/a/vPFau6jtVD8IXEdlCvQFpJxt7wnYWT5qWPHM87+JXk8v7K9OmJUArKNdV
 oA89ie/A1K4OzD9Bapz/W7dxunsV8xdIBHNItUj+w/F7iP2blbMgoSTvYtadZLlT69lp
 pnP/j0mfMLsDx05pmpDOYiCxa08uznpJjDW4qPrtt1kbrq583NUa2AVd08tQpvUPlRjt
 RZhQ==
MIME-Version: 1.0
Received: by 10.224.76.206 with SMTP id d14mr76179002qak.5.1358261734419; Tue,
 15 Jan 2013 06:55:34 -0800 (PST)
Received: by 10.49.96.71 with HTTP; Tue, 15 Jan 2013 06:55:34 -0800 (PST)
Date: Tue, 15 Jan 2013 09:55:34 -0500
Message-ID: <CA+M7sZD6HFa+cP_KwxDcp9G1CEjfOsOs=pmXa+Qd3pD+WfLVAQ@mail.gmail.com>
Subject: Compiling libssh2 with Borland
From: Khaled El Manawhly <k.elmanawhly@gmail.com>
To: libssh2-devel@cool.haxx.se
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============0888403629=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

--===============0888403629==
Content-Type: multipart/alternative; boundary=20cf3074b5a8312c9e04d354f440

--20cf3074b5a8312c9e04d354f440
Content-Type: text/plain; charset=ISO-8859-1

Hi,

Did anybody manage to compile libssh2 with Borland 5.x? I'm pretty new to
make files and I haven't been able to find any online for Borland.

Thanks in advance!

--20cf3074b5a8312c9e04d354f440
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,=A0<div><br></div><div>Did anybody manage to compile li=
bssh2 with Borland 5.x? I&#39;m pretty new to make files and I haven&#39;t =
been able to find any online for Borland.</div><div><br>Thanks in advance!<=
/div>
</div>

--20cf3074b5a8312c9e04d354f440--

--===============0888403629==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============0888403629==--

From libssh2-devel-bounces@cool.haxx.se  Tue Jan 15 21:14:36 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0FKEC8q012645;
	Tue, 15 Jan 2013 21:14:31 +0100
Received: from foo.stuge.se (qmailr@foo.stuge.se [212.116.89.98])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0FKEBx8012621
 for <libssh2-devel@cool.haxx.se>; Tue, 15 Jan 2013 21:14:12 +0100
Received: (qmail 17821 invoked by uid 501); 15 Jan 2013 20:14:11 -0000
Message-ID: <20130115201411.17820.qmail@stuge.se>
Date: Tue, 15 Jan 2013 21:14:11 +0100
From: Peter Stuge <peter@stuge.se>
To: libssh2-devel@cool.haxx.se
Subject: Re: Compiling libssh2 with Borland
Mail-Followup-To: libssh2-devel@cool.haxx.se
References: <CA+M7sZD6HFa+cP_KwxDcp9G1CEjfOsOs=pmXa+Qd3pD+WfLVAQ@mail.gmail.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <CA+M7sZD6HFa+cP_KwxDcp9G1CEjfOsOs=pmXa+Qd3pD+WfLVAQ@mail.gmail.com>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

Khaled El Manawhly wrote:
> Did anybody manage to compile libssh2 with Borland 5.x? I'm pretty new
> to make files and I haven't been able to find any online for Borland.

Maybe someone did very long ago.

Today, I would simply suggest to build your project using gcc instead.


//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Thu Jan 17 02:32:13 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0H1Vl3n022633;
	Thu, 17 Jan 2013 02:32:08 +0100
Received: from homiemail-a58.g.dreamhost.com (caibbdcaaaaf.dreamhost.com
 [208.113.200.5])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0H1VjTq022624
 for <libssh2-devel@cool.haxx.se>; Thu, 17 Jan 2013 02:31:46 +0100
Received: from homiemail-a58.g.dreamhost.com (localhost [127.0.0.1])
 by homiemail-a58.g.dreamhost.com (Postfix) with ESMTP id 1C1767D805B
 for <libssh2-devel@cool.haxx.se>; Wed, 16 Jan 2013 17:31:51 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cantrip.org; h=message-id
 :date:from:mime-version:to:subject:content-type; s=cantrip.org;
 bh=69lK9UYQrAlH5xt2JG/93UNU51Y=; b=P+X7AOpTn/SyQzD4Jg9/Wly1H3UU
 PQP4NbUPO7stExeZ/IqxrDk2cg+zDXWP1PoD5su1yFo1M9797wK1IJu8mjt9Q8MF
 Rzg9+ODxMY3HXSymldMRRldPToOBg6BOTEOAANbzTc5Y5W/PeIx22IDjysIfId3D
 CndJmbpe9tKFJY0=
Received: from [10.0.111.1] (smtp.asperasoft.com [64.201.246.50])
 (using TLSv1 with cipher AES256-SHA (256/256 bits))
 (No client certificate requested)
 (Authenticated sender: ncm@cantrip.org)
 by homiemail-a58.g.dreamhost.com (Postfix) with ESMTPSA id DA6DC7D8058
 for <libssh2-devel@cool.haxx.se>; Wed, 16 Jan 2013 17:31:50 -0800 (PST)
Message-ID: <50F75480.6090500@cantrip.org>
Date: Wed, 16 Jan 2013 17:31:44 -0800
From: Nathan Myers <ncm@cantrip.org>
User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64;
 rv:10.0.11) Gecko/20121123 Icedove/10.0.11
MIME-Version: 1.0
To: libssh2-devel@cool.haxx.se
Subject: receive-window collapse on small reads
Content-Type: multipart/mixed; boundary="------------010802010601070900060307"
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

This is a multi-part message in MIME format.
--------------010802010601070900060307
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

I have code calling libssh2_channel_read_ex() 
<http://www.libssh2.org//libssh2_channel_read_ex.html>, requesting small 
reads,
typically < 100 bytes.  I notice that the receive window size collapses
very quickly, resulting in timeouts when on a high-latency/high-loss
connection, and otherwise running much more slowly than expected.

The attached patch to examples/ssh2_exec.c illustrates the problem.
Manually updating the window, as shown in the #if 0 block, seems
to stabilize the window size, providing a larger window for worse
connections.

Am I using it right?  This code in libssh2_channel_read_ex (src/channel.c)
seems to be at fault:

     if(buflen > recv_window) {
         BLOCK_ADJUST(rc, channel->session,
                      _libssh2_channel_receive_window_adjust(channel, 
buflen,
                                                             1, NULL));
     }

When buflen is small, recv_window can never get large enough to be useful,
even when libssh2's (256K) input buffer is empty.  Is there a recommended
way to keep the window from collapsing, or should clients not be doing
small reads?

This failure did not occur using libssh2-1.2.5.  Running the attached code
(altered just enough to be) linked with 1.2.5 does not exhibit the problem.

Nathan Myers
ncm@cantrip.org


--------------010802010601070900060307
Content-Type: text/x-patch;
 name="slow.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="slow.diff"

--- ../../imports/libssh2/example/ssh2_exec.c	2012-07-04 17:20:19.310258000 -0700
+++ slow.c	2013-01-16 16:57:32.591994303 -0800
@@ -10,7 +10,15 @@
  *
  */
 
+#if 0
 #include "libssh2_config.h"
+#else
+#define HAVE_SYS_SOCKET_H
+#define HAVE_NETINET_IN_H
+#define HAVE_SYS_SELECT_H
+#define HAVE_UNISTD_H
+#define HAVE_ARPA_INET_H
+#endif
 #include <libssh2.h>
 
 #ifdef HAVE_WINSOCK2_H
@@ -73,7 +81,7 @@
 int main(int argc, char *argv[])
 {
     const char *hostname = "127.0.0.1";
-    const char *commandline = "uptime";
+    const char *commandline = "cat /dev/zero";
     const char *username    = "user";
     const char *password    = "password";
     unsigned long hostaddr;
@@ -90,6 +98,13 @@
     LIBSSH2_KNOWNHOSTS *nh;
     int type;
 
+    unsigned long long windowsum = 0;
+    unsigned long calls = 0, windowsize = 0, windowlo = ~0ul, windowhi = 0;
+    unsigned long long then, now;
+    struct timeval tv;
+
+    gettimeofday(&tv, NULL); then = tv.tv_sec * 1000000 + tv.tv_usec;
+
 #ifdef WIN32
     WSADATA wsadata;
     WSAStartup(MAKEWORD(2,0), &wsadata);
@@ -252,16 +267,32 @@
         int rc;
         do
         {
-            char buffer[0x4000];
+            char buffer[10];
             rc = libssh2_channel_read( channel, buffer, sizeof(buffer) );
             if( rc > 0 )
             {
-                int i;
                 bytecount += rc;
-                fprintf(stderr, "We read:\n");
-                for( i=0; i < rc; ++i )
-                    fputc( buffer[i], stderr);
-                fprintf(stderr, "\n");
+
+                ++calls;
+                windowsize = libssh2_channel_window_read_ex(channel, 0,0);
+                if (windowlo > windowsize) windowlo = windowsize;
+                if (windowhi < windowsize) windowhi = windowsize;
+                windowsum += windowsize;
+#if 0  /* a hack: stabilizes window size */
+                libssh2_channel_receive_window_adjust2(channel, rc, 0,0);
+#endif
+                gettimeofday(&tv, NULL);
+                now = tv.tv_sec * 1000000 + tv.tv_usec;
+                if (now - then >= 1000000) {
+                    printf("n=%-6lu wlo=%-6lu whi=%-6lu wav=%-6llu got=%-6d\n",
+                        calls, windowlo, windowhi, windowsum/calls, bytecount);
+                    if (calls > 10 && windowsum == 0)
+                        break;  // busted
+
+                    bytecount = windowhi = windowsum = calls = 0;
+                    windowlo = ~0ul;
+                    then = now;
+                }
             }
             else {
                 if( rc != LIBSSH2_ERROR_EAGAIN )

--------------010802010601070900060307
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--------------010802010601070900060307--

From libssh2-devel-bounces@cool.haxx.se  Thu Jan 17 03:24:46 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0H2O6wG030700;
	Thu, 17 Jan 2013 03:24:38 +0100
Received: from homiemail-a91.g.dreamhost.com (caibbdcaaaaf.dreamhost.com
 [208.113.200.5])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0H2O3Wb030689
 for <libssh2-devel@cool.haxx.se>; Thu, 17 Jan 2013 03:24:03 +0100
Received: from homiemail-a91.g.dreamhost.com (localhost [127.0.0.1])
 by homiemail-a91.g.dreamhost.com (Postfix) with ESMTP id E8191AE05B
 for <libssh2-devel@cool.haxx.se>; Wed, 16 Jan 2013 18:23:56 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cantrip.org; h=message-id
 :date:from:mime-version:to:subject:content-type:
 content-transfer-encoding; s=cantrip.org; bh=AOQUPdKqQH9KF0YQhT7
 703AqgxE=; b=CXWv2A1CRduOiaETCFBnJHBVzTd4WBEYYd4D1II/pRWx2UrtadB
 hNtHjq2f6jxGrlkJdhcCqOB6Pm9cUpON7wrYkCv96YC1zgETQOxyRZpBYcStG05D
 vFnfHMWyqdNt1BzasaKufVlHO3KahcBrffp3UBhePapjMqjkW9T4tpmY=
Received: from [10.0.111.1] (smtp.asperasoft.com [64.201.246.50])
 (using TLSv1 with cipher AES256-SHA (256/256 bits))
 (No client certificate requested)
 (Authenticated sender: ncm@cantrip.org)
 by homiemail-a91.g.dreamhost.com (Postfix) with ESMTPSA id D5507AE059
 for <libssh2-devel@cool.haxx.se>; Wed, 16 Jan 2013 18:23:56 -0800 (PST)
Message-ID: <50F760C4.5060605@cantrip.org>
Date: Wed, 16 Jan 2013 18:24:04 -0800
From: Nathan Myers <ncm@cantrip.org>
User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64;
 rv:10.0.11) Gecko/20121123 Icedove/10.0.11
MIME-Version: 1.0
To: libssh2-devel@cool.haxx.se
Subject: read-window fix?
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

This patch seems to improve matters, for the slow.c just posted.
I'm not sure I understand all the implications of moving the adjust
after the read, but I don't see how to know the right adjustment to
apply without reading first: I very frequently get short reads from
this function.

Nathan Myers
ncm@cantrip.org

diff --git a/src/channel.c b/src/channel.c
index 4f41e1f..4746dc5 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1888,7 +1888,7 @@ LIBSSH2_API ssize_t
  libssh2_channel_read_ex(LIBSSH2_CHANNEL *channel, int stream_id, char 
*buf,
                          size_t buflen)
  {
-    int rc;
+    int rc, rc2;
      unsigned long recv_window;

      if(!channel)
@@ -1896,14 +1896,14 @@ libssh2_channel_read_ex(LIBSSH2_CHANNEL 
*channel, int stream_id, char *buf,

      recv_window = libssh2_channel_window_read_ex(channel, NULL, NULL);

-    if(buflen > recv_window) {
-        BLOCK_ADJUST(rc, channel->session,
-                     _libssh2_channel_receive_window_adjust(channel, 
buflen,
-                                                            1, NULL));
-    }
-
      BLOCK_ADJUST(rc, channel->session,
                   _libssh2_channel_read(channel, stream_id, buf, buflen));
+
+    if (rc > 0) {
+        BLOCK_ADJUST(rc2, channel->session,
+                     _libssh2_channel_receive_window_adjust(channel, rc,
+                                        (buflen > recv_window), NULL));
+    }
      return rc;
  }

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Fri Jan 18 23:32:52 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0IMWRbE015400;
	Fri, 18 Jan 2013 23:32:45 +0100
Received: from mail-qc0-f175.google.com (mail-qc0-f175.google.com
 [209.85.216.175])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0IMWNQe015368
 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Fri, 18 Jan 2013 23:32:24 +0100
Received: by mail-qc0-f175.google.com with SMTP id j3so2723846qcs.6
 for <libssh2-devel@cool.haxx.se>; Fri, 18 Jan 2013 14:32:19 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:x-received:date:message-id:subject:from:to
 :content-type; bh=6bnDjj7UWfLWh3//kJHuZDSJor7lpHK6h0baAq1lgyw=;
 b=m2IxNY68omUa4eb4zFY2HBiRZ856Z6YXyooaVsAKNbrURfdZ7A85B7hAQ72Hkyuh4G
 4b9K2cXzHSC8ZhXWsQTF7OiR2DFhkbTf0z1sfjkg8GaT60+iVPKPl1twmfIowuoJxB1p
 /G04ONH2qjVNpQU3HZm2vN5ioHQTEWU055RgoIvyoQyF9RtysXnUneu1iwPmVWjkHtkV
 dwRRskifoOXrCwKcT8LvgKrt4heVFd91MMB5TpbNkUqteCeZezcojG04VlqHHPtua/Ea
 6jwGhHebhX5mcHiNU138W9bepF1pqULoPHfARvOHwamYMEBkM61a5bO60vZUUJHJmi1w
 J/UQ==
MIME-Version: 1.0
X-Received: by 10.224.222.14 with SMTP id ie14mr10921433qab.61.1358548338806; 
 Fri, 18 Jan 2013 14:32:18 -0800 (PST)
Received: by 10.49.96.71 with HTTP; Fri, 18 Jan 2013 14:32:18 -0800 (PST)
Date: Fri, 18 Jan 2013 17:32:18 -0500
Message-ID: <CA+M7sZA1AM+b8w-HPP2zjh_5e+Q4KGdQKmz-wHGC7pL7G-K1pg@mail.gmail.com>
Subject: FtpFindFirstFile in libssh2?
From: Khaled El Manawhly <k.elmanawhly@gmail.com>
To: libssh2-devel@cool.haxx.se
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============0504910987=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

--===============0504910987==
Content-Type: multipart/alternative; boundary=20cf3074b45c2510b004d397af33

--20cf3074b45c2510b004d397af33
Content-Type: text/plain; charset=ISO-8859-1

Hi, I did a bit of reading online for this, but haven't been able to find a
libssh2 function that does something similar to the wininet
FtpFindFirstFile function. What I need is to check the size of a remote
file via ssh2. Is this possible?

--20cf3074b45c2510b004d397af33
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi, I did a bit of reading online for this, but haven&#39;=
t been able to find a libssh2 function that does something similar to the w=
ininet FtpFindFirstFile function. What I need is to check the size of a rem=
ote file via ssh2. Is this possible?</div>

--20cf3074b45c2510b004d397af33--

--===============0504910987==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============0504910987==--

From libssh2-devel-bounces@cool.haxx.se  Fri Jan 18 23:42:02 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0IMfxEM020767;
	Fri, 18 Jan 2013 23:42:01 +0100
Received: from giant.haxx.se (localhost.localdomain [127.0.0.1])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0IMfwMZ020763
 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Fri, 18 Jan 2013 23:41:58 +0100
Received: from localhost (dast@localhost)
 by giant.haxx.se (8.14.4/8.14.4/Submit) with ESMTP id r0IMfvi4020759
 for <libssh2-devel@cool.haxx.se>; Fri, 18 Jan 2013 23:41:57 +0100
X-Authentication-Warning: giant.haxx.se: dast owned process doing -bs
Date: Fri, 18 Jan 2013 23:41:57 +0100 (CET)
From: Daniel Stenberg <daniel@haxx.se>
X-X-Sender: dast@giant.haxx.se
To: libssh2 development <libssh2-devel@cool.haxx.se>
Subject: Re: FtpFindFirstFile in libssh2?
In-Reply-To: <CA+M7sZA1AM+b8w-HPP2zjh_5e+Q4KGdQKmz-wHGC7pL7G-K1pg@mail.gmail.com>
Message-ID: <alpine.DEB.2.00.1301182341320.18900@tvnag.unkk.fr>
References: <CA+M7sZA1AM+b8w-HPP2zjh_5e+Q4KGdQKmz-wHGC7pL7G-K1pg@mail.gmail.com>
User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
X-fromdanielhimself: yes
MIME-Version: 1.0
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

On Fri, 18 Jan 2013, Khaled El Manawhly wrote:

> Hi, I did a bit of reading online for this, but haven't been able to find a 
> libssh2 function that does something similar to the wininet FtpFindFirstFile 
> function. What I need is to check the size of a remote file via ssh2. Is 
> this possible?

See libssh2_sftp_stat_ex() for getting the size of a remote file.

-- 

  / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Sat Jan 19 00:07:21 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0IN7CbP002806;
	Sat, 19 Jan 2013 00:07:20 +0100
Received: from mail-qa0-f52.google.com (mail-qa0-f52.google.com
 [209.85.216.52])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0IN7ADR002397
 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Sat, 19 Jan 2013 00:07:11 +0100
Received: by mail-qa0-f52.google.com with SMTP id d13so3457582qak.11
 for <libssh2-devel@cool.haxx.se>; Fri, 18 Jan 2013 15:07:06 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:x-received:in-reply-to:references:date:message-id
 :subject:from:to:content-type;
 bh=DFLV2YLMwq3wVOOhhLSIWAXkynzVmJVwxba49legC2Y=;
 b=SW0RSYq/lT812YL/npQiCB7+u/xUSZ9rwF5zDXwmsTlT4MR5XW4C0EX5GjQ7NDol9h
 22FunuzReDeUcbqD4D4YNw3yKd0Qc6VwBkuHZyz9/Dq6AIYRLny3zsVvvfCbVjCCck/V
 uJ9jCFZFFdg2yR5Yp7x5Yf5lLurDpiVU/zbN4NX7dwAIt7UxSblnQKWE1HVtHaBzB22l
 /hi/SI/UIcIBIUMFZ5uGHGddWaip6kX6J8uk3XaWUK1Osb0dO+2EdXlOUnhDAteoS+Ru
 m+Q4BmRV53VXlkBN4TSKMALfwMvVVzTHD9jPafjXz3EfHL1ZffNGuYm9r7NbnCYJLamo
 8nFg==
MIME-Version: 1.0
X-Received: by 10.224.31.209 with SMTP id z17mr11408833qac.28.1358550426824;
 Fri, 18 Jan 2013 15:07:06 -0800 (PST)
Received: by 10.49.96.71 with HTTP; Fri, 18 Jan 2013 15:07:06 -0800 (PST)
In-Reply-To: <alpine.DEB.2.00.1301182341320.18900@tvnag.unkk.fr>
References: <CA+M7sZA1AM+b8w-HPP2zjh_5e+Q4KGdQKmz-wHGC7pL7G-K1pg@mail.gmail.com>
 <alpine.DEB.2.00.1301182341320.18900@tvnag.unkk.fr>
Date: Fri, 18 Jan 2013 18:07:06 -0500
Message-ID: <CA+M7sZC6yLYgjtEY08y1K+y5PE9Ztn3B0fpkxW1Pif5nAUO4hw@mail.gmail.com>
Subject: Re: FtpFindFirstFile in libssh2?
From: Khaled El Manawhly <k.elmanawhly@gmail.com>
To: libssh2 development <libssh2-devel@cool.haxx.se>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1784378211=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

--===============1784378211==
Content-Type: multipart/alternative; boundary=20cf3074afc899b1b404d3982bef

--20cf3074afc899b1b404d3982bef
Content-Type: text/plain; charset=ISO-8859-1

>  Hi, I did a bit of reading online for this, but haven't been able to find
>> a libssh2 function that does something similar to the wininet
>> FtpFindFirstFile function. What I need is to check the size of a remote
>> file via ssh2. Is this possible?
>>
>
> See libssh2_sftp_stat_ex() for getting the size of a remote file.
>
> Thanks Dan, that helps a lot!

--20cf3074afc899b1b404d3982bef
Content-Type: text/html; charset=ISO-8859-1

<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hi, I did a bit of reading online for this, but haven&#39;t been able to find a libssh2 function that does something similar to the wininet FtpFindFirstFile function. What I need is to check the size of a remote file via ssh2. Is this possible?<br>

</blockquote>
<br>
See libssh2_sftp_stat_ex() for getting the size of a remote file.<span class=""><font color="#888888"><br><br>
</font></span></blockquote></div>Thanks Dan, that helps a lot!<br></div></div>

--20cf3074afc899b1b404d3982bef--

--===============1784378211==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============1784378211==--

From libssh2-devel-bounces@cool.haxx.se  Thu Jan 31 15:37:48 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0VEbHfp025814;
	Thu, 31 Jan 2013 15:37:41 +0100
Received: from earth.stuge.se (earth.stuge.se [212.116.89.126])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0VEbGmM025806
 for <libssh2-devel@cool.haxx.se>; Thu, 31 Jan 2013 15:37:16 +0100
Received: (qmail 2483 invoked from network); 31 Jan 2013 14:37:12 -0000
Received: from unknown (HELO earth.stuge.se) (127.0.0.1)
 by localhost with SMTP; 31 Jan 2013 14:37:12 -0000
MIME-Version: 1.0
From: "libssh2 Trac" <trac@libssh2.stuge.se>
X-Trac-Version: 1.0dev
Precedence: bulk
Cc: libssh2-devel@cool.haxx.se
Auto-Submitted: auto-generated
X-Mailer: Trac 1.0dev, by Edgewall Software
X-Trac-Project: libssh2
Date: Thu, 31 Jan 2013 14:37:12 -0000
X-URL: https://trac.libssh2.org/
Subject: [libssh2] #255: libssh2_channel_write_ex returns zero
X-Trac-Ticket-URL: https://trac.libssh2.org/ticket/255
Message-ID: <040.5aafc3bcbc4ccf76c260e9c86bdfe77f@libssh2.stuge.se>
X-Trac-Ticket-ID: 255
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id r0VEbGmM025806
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Reply-To: trac@libssh2.stuge.se,
        libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

#255: libssh2_channel_write_ex returns zero
--------------------+--------------------
 Reporter:  ncm     |       Owner:
     Type:  defect  |      Status:  new
 Priority:  normal  |   Milestone:  1.4.3
Component:  misc    |     Version:  1.4.2
 Keywords:          |  Blocked By:
   Blocks:          |
--------------------+--------------------
 Sometimes {{{libssh2_channel_write_ex()}}} returns zero when writing from
 a
 non-zero-length buffer.  As I understand it, this should never happen:
 it should either return a positive number of bytes written, or a negative
 value such as {{{_EAGAIN}}}.

 The zero may be coming from {{{src/channel.c}}},
 {{{_libssh2_channel_write()}}}, c. line 2015, when rc is zero:
 {{{
    if(channel->local.window_size <= 0)
        /* there's no room for data so we stop */
        return (rc==LIBSSH2_ERROR_EAGAIN?rc:0);
 }}}
 {{{rc}}} gets its value from {{{_libssh2_transport_read()}}}, which
 returns zero
 when {{{session->socket_state}}} is {{{LIBSSH2_SOCKET_DISCONNECTED}}}.  I
 have not
 discovered any other way for {{{_transport_read()}}} to return zero.

 Another way for {{{_write_ex()}}} to return zero would be if
 {{{channel->local.packet_size}}} were to be set to zero.

 Also, it seems as if {{{session->socket_block_directions}}} should
 be assigned {{{LIBSSH2_SESSION_BLOCK_INBOUND}}} when
 {{{channel->local.window_size}}} is found to be zero, but it is not.

-- 
Ticket URL: <https://trac.libssh2.org/ticket/255>
libssh2 <https://trac.libssh2.org/>
C library for writing portable SSH2 clients

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Thu Jan 31 15:37:50 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0VEbmma025945;
	Thu, 31 Jan 2013 15:37:50 +0100
Received: from earth.stuge.se (earth.stuge.se [212.116.89.126])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0VEbijD025926
 for <libssh2-devel@cool.haxx.se>; Thu, 31 Jan 2013 15:37:44 +0100
Received: (qmail 2606 invoked from network); 31 Jan 2013 14:37:43 -0000
Received: from unknown (HELO earth.stuge.se) (127.0.0.1)
 by localhost with SMTP; 31 Jan 2013 14:37:43 -0000
MIME-Version: 1.0
From: "libssh2 Trac" <trac@libssh2.stuge.se>
X-Trac-Version: 1.0dev
Precedence: bulk
Cc: libssh2-devel@cool.haxx.se
Auto-Submitted: auto-generated
X-Mailer: Trac 1.0dev, by Edgewall Software
X-Trac-Project: libssh2
Date: Thu, 31 Jan 2013 14:37:43 -0000
X-URL: https://trac.libssh2.org/
Subject: [libssh2] #256: many writes, congested link -> LIBSSH2_ERROR_BAD_USE, 
 stuck
X-Trac-Ticket-URL: https://trac.libssh2.org/ticket/256
Message-ID: <040.9cc8a4935ffb9ba017602a502ffabbc6@libssh2.stuge.se>
X-Trac-Ticket-ID: 256
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id r0VEbijD025926
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Reply-To: trac@libssh2.stuge.se,
        libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

#256: many writes, congested link -> LIBSSH2_ERROR_BAD_USE, stuck
--------------------+--------------------
 Reporter:  ncm     |       Owner:
     Type:  defect  |      Status:  new
 Priority:  normal  |   Milestone:  1.4.3
Component:  misc    |     Version:  1.4.2
 Keywords:          |  Blocked By:
   Blocks:          |
--------------------+--------------------
 I am using libssh2 in an application that reads and writes many
 small blocks (<200 bytes) on a connection that blocks frequently.
 Occasionally a write returns LIBSSH2_ERROR_BAD_USE (-39).  Once
 this occurs, no subsequent write succeeds.

 It turns out this happens when a window-adjust packet send() call
 (e.g. during {{{libssh2_channel_read()}}}) returns a short write,
 leaving {{{p->odata}}} pointing to the channel-adjust buffer.
 Sending another window-adjust would unstick it, but
 no code path provoked by normal code evokes that.

 It could happen with keepalive packets too, although I have
 not seen it yet.

 The patch attached may be the right way to fix it.

-- 
Ticket URL: <https://trac.libssh2.org/ticket/256>
libssh2 <https://trac.libssh2.org/>
C library for writing portable SSH2 clients

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Thu Jan 31 15:38:20 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0VEcKYF026279;
	Thu, 31 Jan 2013 15:38:20 +0100
Received: from earth.stuge.se (earth.stuge.se [212.116.89.126])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0VEcIR3026275
 for <libssh2-devel@cool.haxx.se>; Thu, 31 Jan 2013 15:38:18 +0100
Received: (qmail 2716 invoked from network); 31 Jan 2013 14:38:18 -0000
Received: from unknown (HELO earth.stuge.se) (127.0.0.1)
 by localhost with SMTP; 31 Jan 2013 14:38:18 -0000
MIME-Version: 1.0
From: "libssh2 Trac" <trac@libssh2.stuge.se>
X-Trac-Version: 1.0dev
Precedence: bulk
Cc: libssh2-devel@cool.haxx.se
Auto-Submitted: auto-generated
X-Mailer: Trac 1.0dev, by Edgewall Software
X-Trac-Project: libssh2
Date: Thu, 31 Jan 2013 14:38:18 -0000
X-URL: https://trac.libssh2.org/
Subject: Re: [libssh2] #250: libssh2_channel_send_eof() sometimes fails when
 used in non-blocking mode
X-Trac-Ticket-URL: https://trac.libssh2.org/ticket/250#comment:1
Message-ID: <060.9c82b00198be2b41179e5fcfa15fd9e8@libssh2.stuge.se>
References: <045.71dc68c0246eaefb66a5712cf86a4fa0@libssh2.stuge.se>
X-Trac-Ticket-ID: 250
In-Reply-To: <045.71dc68c0246eaefb66a5712cf86a4fa0@libssh2.stuge.se>
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id r0VEcIR3026275
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Reply-To: trac@libssh2.stuge.se,
        libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

#250: libssh2_channel_send_eof() sometimes fails when used in non-blocking mode
-----------------------+-------------------------------------------
  Reporter:  jfriesne  |      Owner:
      Type:  defect    |     Status:  new
  Priority:  normal    |  Milestone:  1.4.3
 Component:  API       |    Version:  1.4.2
Resolution:            |   Keywords:  non-blocking channel_send_eof
Blocked By:            |     Blocks:
-----------------------+-------------------------------------------

Comment (by ncm):

 I agree that this change is needed.

-- 
Ticket URL: <https://trac.libssh2.org/ticket/250#comment:1>
libssh2 <https://trac.libssh2.org/>
C library for writing portable SSH2 clients

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Thu Jan 31 20:06:10 2013
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0VJ5iDx026481;
	Thu, 31 Jan 2013 20:06:05 +0100
Received: from mail-qe0-f46.google.com (mail-qe0-f46.google.com
 [209.85.128.46])
 by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id r0VJ5fn9026395
 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Thu, 31 Jan 2013 20:05:42 +0100
Received: by mail-qe0-f46.google.com with SMTP id 1so1426241qec.5
 for <libssh2-devel@cool.haxx.se>; Thu, 31 Jan 2013 11:05:36 -0800 (PST)
X-Received: by 10.224.212.9 with SMTP id gq9mr10194090qab.47.1359659136686;
 Thu, 31 Jan 2013 11:05:36 -0800 (PST)
Received: from mail-qa0-f41.google.com (mail-qa0-f41.google.com
 [209.85.216.41])
 by mx.google.com with ESMTPS id dt10sm5063698qab.0.2013.01.31.11.05.34
 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
 Thu, 31 Jan 2013 11:05:35 -0800 (PST)
Received: by mail-qa0-f41.google.com with SMTP id hy16so3058531qab.0
 for <libssh2-devel@cool.haxx.se>; Thu, 31 Jan 2013 11:05:33 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=x-received:mime-version:from:date:message-id:subject:to
 :content-type; bh=JPjhJUK6MKVIj+KRCWyW6DNlT7M0FxFwClMhck7BYPM=;
 b=JLrjbH4elJIEcjt7SsaIDgrh5RPR6aME+E4itmZPxmjm9NedPFCyYXoAcVrYrQzxEK
 3n5Z2heaB/kM4qGR9TxQS2Skj+ktumOgKkUnIwSMKuExqSXnLt/Mv/TaVoYkvgwidu2j
 77m5ZB/VqDQxU6Ra+uSxgFywGCq3NhxCQr+VWeu1r1fYRoKY31BksAGy0R9JDpHJxuGE
 5p0JirN39Sef2mluog2pDV5Y0+Ivw7lzq4YHyJunVBoMvXk5XpJjD/xlY2paTHljQadk
 QVahB+LKkiKZrp1kx/95+KLKxTt35bgVSEDpF6wm/EOdfZ4M14R94wTCLCxaOOtrTKZM
 kQPA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=google.com; s=20120113;
 h=x-received:mime-version:from:date:message-id:subject:to
 :content-type:x-gm-message-state;
 bh=JPjhJUK6MKVIj+KRCWyW6DNlT7M0FxFwClMhck7BYPM=;
 b=ftriFfCXdRJiUTViV5LoCWDcMqvHodYGEVZ0T+BUcZU5nHNjOMHa6KoSRHUNjmASoq
 h0EKJbHrFq+y8YiHnXg23jL9kGsmDXlzsy4LOtjyT1pxy+8MQ+wjdyCDV49UzOdTFmkj
 S0Xuzd9SJInWwALsPICi7mYrmb+3lXBJ4x0HlxFbpG/AVTdCmF2puq1QfRnpIPjWQcM7
 0MY0FHylEUCLyOXq/rS1gtzm62Ocd+to+hfNQ6XyK4G6jYhstaAEHd5jxVEPQZGZhC6p
 xfeI/GTGDsNK7q1ZD0xcql78EKE+CZtYibkl55GNzM68+UTU0s3Iyy/mU8yV3+7phDLz
 V6qQ==
X-Received: by 10.224.58.147 with SMTP id g19mr10109581qah.22.1359659133589;
 Thu, 31 Jan 2013 11:05:33 -0800 (PST)
MIME-Version: 1.0
Received: by 10.49.96.66 with HTTP; Thu, 31 Jan 2013 11:05:12 -0800 (PST)
From: Aristidis Zoutsos <azouts@gmail.com>
Date: Thu, 31 Jan 2013 21:05:12 +0200
Message-ID: <CAPoy1UKE-EWw4Up2e-GrBLty+7hyFPURpa9SPxKfTXyqLw=WJA@mail.gmail.com>
Subject: libssh2_channel_direct_tcpip_ex
To: libssh2-devel@cool.haxx.se
X-Gm-Message-State: ALoCoQl6gI3m/OwoiiIAcN4WDNETAk+IpCoJ2Inu7cVDmvjcsM4nGRdBls933KfAYNueTm0HBlod
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============0239202549=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>

--===============0239202549==
Content-Type: multipart/alternative; boundary=20cf3074d248ac591c04d49a4f7f

--20cf3074d248ac591c04d49a4f7f
Content-Type: text/plain; charset=UTF-8

Hi,

I open a direct tcpip channel to forward a local port to an http 1.1 proxy.

I send a request and when I get the response back, the channel receives the
channel EOF (HTTP proxy closes the connection). After that the channel
seems not usable anymore so I close and free the channel and then I try to
reestablish a new direct tcpip channel. However it cannot reestablish a new
channel so I have to disconnect the whole session and start a new one.

Is this the correct way to make the http tunnel or is something wrong?

This way the loading of a page with many requests has to open many sessions
and authenticate again and again and it is slow.

--20cf3074d248ac591c04d49a4f7f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi,<div><br></div><div>I open a direct tcpip channel to forward a local por=
t to an http 1.1 proxy.=C2=A0</div><div><br></div><div>I send a request and=
 when I get the response back, the channel receives the channel EOF (HTTP p=
roxy closes the connection). After that the channel seems not usable anymor=
e so I close and free the channel and then I try to reestablish a new direc=
t tcpip channel. However it cannot reestablish a new channel so I have to d=
isconnect the whole session and start a new one.</div>

<div><br></div><div>Is this the correct way to make the http tunnel or is s=
omething wrong?=C2=A0</div><div><br></div><div>This way the loading of a pa=
ge with many requests has to open many sessions and authenticate again and =
again and it is slow.</div>

<div><br></div>

--20cf3074d248ac591c04d49a4f7f--

--===============0239202549==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============0239202549==--

