Welcome Guest, Not a member yet? Register   Sign In
curl question
#1

[eluser]ronnie_nsu[/eluser]
hi Guys
I have this following code which actually tries to get content of three website with curl
Code:
$nodes = array(
            'http://localhost:8080/ngbdcart/index.php/checkout_shipping/run_carrier/run',
            'www.microsoft.com',
            'www.newgenbd.net'
        );
        $node_count = count($nodes);

        $curl_arr = array();
        $master = curl_multi_init();

        for ($i = 0; $i < $node_count; $i++) {
            $url = $nodes[$i];
            $curl_arr[$i] = curl_init($url);
            curl_setopt($curl_arr[$i], CURLOPT_HEADER, 0);
            curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl_arr[$i], CURLOPT_TIMEOUT, 30);
            curl_multi_add_handle($master, $curl_arr[$i]);
        }
        $running = NULL;
        do {
            curl_multi_exec($master, $running);
            usleep (250000);
        } while ($running > 0);

        echo "results: <br/>";
        for ($i = 0; $i < $node_count; $i++) {
            $results = curl_multi_getcontent($curl_arr[$i]);
            echo $results;
            curl_multi_remove_handle($master,$curl_arr[$i]);
        }
        curl_multi_close($master);
        echo 'done';

the problem is the i get output from last two urls in the $nodes array...but for the locahost.. one i get response randomly...
and the run() function is a very simple it just echos one word "Helloooo"

anyone knows how to solve this problem???
Thanks in advance
#2

[eluser]Nick_MyShuitings[/eluser]
First I would recommend switching the order of the items in the $nodes array. This is just from a tester standpoint to make sure it is indeed related to the path chosen, and not to the position as first in the array.

From there once you have actually confirmed that it is the localhost path which is problematic, you can choose to attack it more directly.

Question: Why are you attempting a curl of a localhost url? Is it always going to be localhost? Perhaps using a virtualhost would allow you to test against a url that is more similar to the final solution.
#3

[eluser]ronnie_nsu[/eluser]
[quote author="Nick_MyShuitings" date="1284161231"]First I would recommend switching the order of the items in the $nodes array. This is just from a tester standpoint to make sure it is indeed related to the path chosen, and not to the position as first in the array.

From there once you have actually confirmed that it is the localhost path which is problematic, you can choose to attack it more directly.

Question: Why are you attempting a curl of a localhost url? Is it always going to be localhost? Perhaps using a virtualhost would allow you to test against a url that is more similar to the final solution.[/quote]

Thanks Nick!!
But i think i just figured out the problem.curl doesnt like the word localhost..i am using 127.0.0.1..and its working like a charm11




Theme © iAndrew 2016 - Forum software by © MyBB