2

Is it possible to make asynchronous connections with Zend_Http? How?

Thanks for help.

Charles
  • 50,943
  • 13
  • 104
  • 142
Stil
  • 21
  • 1
  • 2

2 Answers2

2

No. Zend_Http does neither support parallel requests (look into curl_multi for that) nor asynchronous requests or response polling. All adapters are ->read right after the request ->write.

mario
  • 144,265
  • 20
  • 237
  • 291
  • 1
    Yes, Without getting exotic (and possibly daft), curl_multi is about the only easy way to this. There some old (but still correct) tutorials about the basics of how to do this. http://www.paul-norman.co.uk/2009/06/asynchronous-curl-requests/ – James Butler Mar 17 '11 at 00:09
  • 3
    @JamesButler: There is also a newfangled way to do it: http://php.net/httprequestpool - And it would be (here comes a overly hypothetical assumption) possible to build something yourself using a fsockopen pool. But in PHP it's hard to make it either efficient or really asynchronous. – mario Mar 17 '11 at 00:18
  • Hadn't noticed that. I'm guessing its a wrapper/abstraction over curl. Everyday is a school day! – James Butler Mar 17 '11 at 10:14
0

Yes it is possible, though an not a natural solution, but ...

try {
    $result = $client->request(Zend_Http_Client::GET);
} catch (Exception $ex) {
    //no hadle
}

and provide timeout value of 1

$client = new Zend_Http_Client("http://127.0.0.1:80......."", array(
    'timeout'      => 1
));
Grigor Nazaryan
  • 567
  • 5
  • 18