gpt4 book ai didi

c - 从终端主机读取直播流数据

转载 作者:可可西里 更新时间:2023-11-01 02:49:16 24 4
gpt4 key购买 nike

我正在使用终端作为主机来输入数据(通过将任意字符集复制/粘贴到终端中)。我想在我的应用程序中捕获此数据流。

我正在使用 this code sample作为客户端来听主机。但是,我收到的输出是一个小字符串,不等于缓冲区的大小。我预计代码会打印出等于缓冲区大小的字符串。

> buffer size = 100;
> --
> sample input (copy/pasted into terminal): "here is a random string"
>
> current output: "h"
> expected output: "here is a random string"

我如何捕获这个“实时”数据流并使输出与缓冲区一致,而不是一个小字符串?

最佳答案

经过一些调查,recv() 函数不能保证收集到我想要的所有 数据。

为此,我遵循了:https://stackoverflow.com/a/12696176/1121302

现在,我得到了预期的输出。

关于c - 从终端主机读取直播流数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19102851/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com