共 15 篇文章 |
|
阅30 转0 评0 公众公开 15-03-03 22:40 |
基于curl的异步http实现。线程模型:这里实现异步一般会开线程,假定有一个UI(主)线程,可能有这些模式:Manager在UI线程中管理若干个工作线程,curl_easy接口。开多个work线程浪费资源,线程管理难度大,线程并发度的减少不会造成性能瓶颈,因为主要耗时在网络IO上。// bad case,在处理请求时,完成的task已经进入调用者线程的task队列 } ... 阅33 转0 评0 公众公开 15-03-03 21:06 |
// 设置easy handle easy_handle1 = curl_easy_init(); curl_easy_setopt(easy_handle1, CURLOPT_URL, "http://www.sina.com.cn"); curl_easy_setopt(easy_handle1, CURLOPT_WRITEFUNCTION, &save_sina_page); curl_easy_setopt(easy_handle1, CURLOPT_WRITEDATA, fp_sina);// 添加到multi stack curl_multi_add_... 阅855 转5 评0 公众公开 15-03-03 20:56 |
关于使用libcurl的注意事项 (1), 超时(timeout) libcurl 是一个很不错的库,支持http,ftp等很多的协议。CURLcode curl_global_init(long flags);通常情况,如果不显式的调用它,第一次调用curl_easy_init()时,curl_easy_init 会调用curl_global_init,在单线程环境下,这不是问题。在多个线程中调用curl_easy_int,然后如果两个线程同时... 阅38 转0 评0 公众公开 15-03-03 20:40 |
libcurl多线程超时设置不安全。通常情况,如果不显式的调用它,第一次调用 curl_easy_init()时,curl_easy_init 会调用 curl_global_init,在单线程环境下,这不是问题。在多个线 程中调用curl_easy_int,然后如果两个线程同时发现curl_global_init还没有被调用,同时调用 curl_global_init,悲剧就发生了。调用libcurl下载,然后使用netstat查... 阅92 转0 评0 公众公开 15-03-03 20:39 |
阅122 转0 评0 公众公开 14-11-22 20:57 |
基于curl的异步http实现。线程模型:这里实现异步一般会开线程,假定有一个UI(主)线程,可能有这些模式:Manager在UI线程中管理若干个工作线程,curl_easy接口。开多个work线程浪费资源,线程管理难度大,线程并发度的减少不会造成性能瓶颈,因为主要耗时在网络IO上。// bad case,在处理请求时,完成的task已经进入调用者线程的task队列 } ... 阅1298 转0 评0 公众公开 14-11-22 20:56 |
用vs2010打开zlib-1.2.5/old/visualc6/zlib.dsw,选择DLL_Release编译,把编译生成的zlib-1.2.5/old/visualc6/Win32_DLL_Release/zlib1.lib复制到curl-7.26.0/lib目录下,重命名为 zdll.lib (注意必须为此文件名)。call "C:/Program Files/Microsoft Visual Studio 10.0/VC/bin/vcvars32.bat"set CFG=release-dll-ssl-dll-zlib-dll... 阅470 转1 评0 公众公开 14-10-28 16:08 |
[Redirection 3xx]$http_code["300"]=”Multiple Choices”;$http_code["301"]=”Moved Permanently”;$http_code["302"]=”Found”;$http_code["303"]=”See Other”;$http_code["304"]=”Not Modified”;$http_code["305"]=”Use Proxy”;$http_code["306"]=”(Unuse... 阅180 转1 评0 公众公开 14-10-28 15:13 |
curl_setopt($ch, CURLOPT_URL, $url);if ($SSL &&$CA) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);复制代码 代码如下:curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); // 只信任CA颁布的证书 curl_setopt($ch, CURLOPT_CAINFO, $cacert); // CA根证书(用来验证的网站证书是否是CA颁布) curl_setopt($ch, CURLO... 阅64 转0 评0 公众公开 14-10-28 15:02 |