当执行的命令返回的结果数据量较大时,libssh2_channel_read()只能读取channel的一部分,不知道怎样才能读取全部的数据。
//下面是读取channel的代码
for( ;; )
{
libssh2_channel_receive_window_adjust(channel, LIBSSH2_CHANNEL_MINADJUST*5, 1);
int rc1;
do
{
char buffer[0x4000];
rc1 = libssh2_channel_read( channel, buffer, sizeof(buffer) ); //读数据
count = count + rc1; //记录输出的字节数
if( rc1 > 0 )
{
result = [NSString stringWithFormat:@"%s",buffer];
}
}
while( rc1 > 0 );
/* this is due to blocking that would occur otherwise so we loop on
this condition */
if( rc1 == LIBSSH2_ERROR_EAGAIN )
{
waitsocket(sock, session);
}
else
break;
}
------------------------------结果----------------------
2014-10-17 10:28:30.747 WiFiset[645:60b] ================================
28248 //本次读取字节数。(总字节数不止这个数)
2014-10-17 10:28:30.748 WiFiset[645:60b] ----- ms ago
Information elements from Probe Response frame:
SSID: WiFi1111
Capabilities: 0x11ef
(......中间省略......)
TIM: DTIM Count 0 DTIM Period 2 Bitmap Control 0x0 Bitmap[0] 0x0
ERP: Barker_Preamble_Mode
Extended supported rates //“rates”后面还有很多数据