t407289575 2014-10-06 08:31 采纳率: 0%
浏览 4374

急!!libssh2_channel_read()无法返回全部数据

当执行的命令返回的结果数据量较大时,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”后面还有很多数据
  • 写回答

1条回答

  • weixin_41782355 2022-03-11 14:10
    关注

    哥们,你这个怎么解决的,遇到了同样的问题。

    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码