使用stream_socket_client同时检索2个远程文件

发布于 2024-09-01 13:47:36 字数 161 浏览 1 评论 0原文

我有一个 PHP 脚本,它检索两个非常相似的文件并对数据执行一些任务,然后输出结果。我目前正在使用curl并获取一个并处理它,然后获取另一个并处理它。

我想切换到stream_socket_client,因为我听说您可以同时检索这两个文件,并在检索到它们后进行处理,但我不确定如何执行此操作。

I have a script in PHP which retrieves two very similar files and performs some tasks on the data then outputs a result. I'm currently using curl and getting one, processing it, then getting the other and processing it.

I want to switch to stream_socket_client as I've heard you can retrieve both files at the same time and do the processing once they have been retrieved but I am unsure how to do this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

做个少女永远怀春 2024-09-08 13:47:36

请参阅此博文。基本上,您打开两个套接字,使用 false 调用stream_set_blocking,然后在循环中调用 fread 直到两个流都达到 EOF。

See this blog post. Basically, you open both sockets, call stream_set_blocking with false, and in a loop you call fread until both streams reach EOF.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文