Does phpcurl determine the url from which the data is captured by multiple threads?

Source: Internet
Author: User
Does phpcurl determine the URLs from which the data is captured by multiple threads? & Nbsp; $ mh & nbsp ;=& nbsp; curl_multi_init (); & nbsp; // & nbsp; enable multithreading & nbsp; $ I & nbsp ;=& nbsp; 0; & nbsp; & nbs php curl: can I determine the URLs from which the data is captured by multiple threads?
$ Mh = curl_multi_init (); // enable multithreading

$ I = 0;
Foreach ($ url_array as $ url ){
$ Ch = curl_init ();
If (IS_PROXY ){
Curl_setopt ($ ch, CURLOPT_PROXY, '67. 215.228.129: 8089 '); // 60.12.226.18
}
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // return don't print
Curl_setopt ($ ch, CURLOPT_TIMEOUT, 30); // Set the timeout value.
Curl_setopt ($ ch, CURLOPT_USERAGENT, 'mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0 )');
Curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 1); // 302 redirect
Curl_setopt ($ ch, CURLOPT_MAXREDIRS, 7); // HTTp targeting level
Curl_multi_add_handle ($ mh, $ ch); // put curl resource into multi curl handler
$ Handle [$ I ++] = $ ch;
}


The code above enables multi-threaded data capturing. if I add 10 URLs at a time, an array with 10 results is returned to me. I cannot determine which url the data comes from.
Is there any way, or which other language can implement it, and the data captured by multiple threads still knows the url from which it comes from. Share:
------ Solution --------------------
You can accurately obtain the detailed information of each curl using curl_getinfo ($ handle [$ I ]).
This is roughly the case (you can also read only the parts you are interested in)
    [url] => http://blog.51edm.org/content/uploadfile/201303/dc7f1364286796.zip
    [content_type] => application/zip
    [http_code] => 206
    [header_size] => 313
    [request_size] => 221
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.047
    [namelookup_time] => 0
    [connect_time] => 0.047
    [pretransfer_time] => 0.047
    [size_upload] => 0
    [size_download] => 201
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => 201
    [upload_content_length] => 0
    [starttransfer_time] => 0.078
    [redirect_time] => 0
    [certinfo] => Array
        (
        )

    [primary_ip] => 119.37.197.49
    [primary_port] => 80

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.