php curl_multi_exec 一定要在 curl_multi_select之前调用原因分析


curl_multi_exec 本质上是多个套接字同时在发起请求,传输数据 epoll 多个套接字 (低层是使用libcurl网络库 + epoll 实现)
而单个curl_exec 是直接建立socket 上面封装协议 同步数据传输

curl_multi_select 之前木有调用curl_multi_exec 则始终返回-1 (因为木有执行curl_multi_exec, 则木有connect 内部使用了延迟连接特性)

curl_multi_exec 返回的是整个curl栈状态,及时返回curl_ok 个别curl传输依然是有问题de

Description:
------------
curl_multi_select() seems broken in PHP 5.3.18 on CentOS 6.3.

The behavior of the test script below is different than it used to be, returning 
immediately without select with a -1 (failure) return value.


Test script:
---------------
$mh = curl_multi_init();
print curl_multi_select($mh, 1.0);
curl_multi_close($mh);


Expected result:
----------------
curl_multi_select() should take 1.0 seconds to complete and returns 0

Actual result:
--------------
curl_multi_select() returns immediately with return value of -1








参考文献

http://blog.csdn.net/linkaisheng101990/article/details/49557483

http://php.net/manual/en/function.curl-multi-exec.php

http://blog.marchtea.com/archives/109

https://bugs.php.net/bug.php?id=63411

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值