简体   繁体   English

没有cURL_multi的PHP cURL多线程,怎么办?

[英]PHP cURL multithreading without curl_multi, how to?

I know it's most likely a very dumb question to ask, and I've been using curl_multi and classes such as https://github.com/petewarden/ParallelCurl/ for multithreading. 我知道这很可能是一个非常愚蠢的问题,并且我一直在使用curl_multi和诸如https://github.com/petewarden/ParallelCurl/之类的多线程。

But recently I came across this building a web proxy, an open-source PHP web proxy framework called glype . 但是最近我碰到了这个构建Web代理的过程,Web代理是一个名为glype的开源PHP Web代理框架。

it seems to me all resources are fetched by cURL, and there's no curl_multi in its source code whatsoever, the code contains only curl_init and curl_exec. 在我看来,所有资源都是通过cURL获取的,并且其源代码中没有curl_multi,该代码仅包含curl_init和curl_exec。

That said, img's (and probably other src too) load concurrently, I briefly went through the code, but failed to find a clue how it works this way. 就是说,img(可能还有其他src)同时加载,我简要地检查了一下代码,但是没有找到线索以这种方式工作。

Anyone have tried multithreading cURL without using curl_multi? 有人尝试过不使用curl_multi的多线程cURL吗? (PHP pthread not included) (不包括PHP pthread)

cURL Multi has nothing whatever to do with multi-threading, or parallelism. cURL Multi与多线程或并行性无关。

cURL Multi is a set of functions within the cURL extension that use non-blocking I/O for asynchronous execution of requests. cURL Multi是cURL扩展内的一组函数,这些函数使用非阻塞I / O来异步执行请求。

To be clear, cURL Multi is not parallel, nor multi-threaded: It facilitates non-blocking asynchronous I/O. 需要明确的是,cURL Multi不是并行的,也不是多线程的:它促进了非阻塞异步I / O。

Glype uses the processing model of the server serving the code: When your browser requests a page through Glype, the server is responsible for creating (or reusing) the process that executes Glype. Glype使用提供代码的服务器的处理模型:当您的浏览器通过Glype请求页面时,服务器负责创建(或重用)执行Glype的进程。 In the same way, when the page requests resources like CSS or images from the server, it is the server that creates (or re-uses) a process, which in turn executes the PHP interpreter, which in turn executes Glype. 同样,当页面从服务器请求CSS或图像之类的资源时,是服务器创建(或重复使用)进程,该进程又执行PHP解释器,而该PHP解释器又执行Glype。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM