man curl_easy_perform(原创)
curl_easy_perform(3) libcurl 手册 curl_easy_perform(3)
名字
curl_easy_perform - 执行一个阻塞文件传输
摘要
#include <curl/curl.h>
CURLcode curl_easy_perform(CURL *easy_handle);curl_easy_perform
描述
调用此函数后会默认调用curl_easy_init(3)和所有的curl_easy_setopt(3),并将执行所述选项中所述的传输。它必须被easy_handle作为输入的curl_easy_init相同(3)调用返回。curl_easy_perform(3)执行一个阻塞的方式和返回时完成整个请求,或者如果它失败了。非阻塞的行为,看到curl_multi_perform(3)。
你可以做任何数量的要求curl_easy_perform(3)同时使用相同的easy_handle。如果你打算传输一个以上的文件,你甚至鼓励这样做。libcurl将试图使用相同的连接的传输,从而使作品‐tions更快,更少的CPU密集使用较少的网络资源。只是注意,你将不得不使用curl_easy_setopt(3)之间的调用为以下curl_easy_perform设置选项。
你必须调用这个函数同时使用相同的easy_handle两地。让函数返回前先调用另一个时间。如果你想要并行传输,必须使用多个卷easy_handles。
而easy_handle添加到多处理,不能用curl_easy_perform(3)。
返回值:
curle_ok(0)意味着一切都是好的,非零均值发生错误 <curl/curl.h> 定义见libcURL错误(3)。如果我‐lopt_errorbuffer(3)是集curl_easy_setopt(3)会有一个可读的错误的错误消息时,非零返回缓冲区。
范例
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
请参考
curl_easy_init(3), curl_easy_setopt(3), curl_multi_add_handle(3), curl_multi_perform(3), libcurl-errors(3),
libcurl 7.7 5 Mar 2001 curl_easy_perform(3)
原文:
1 curl_easy_perform(3) libcurl Manual curl_easy_perform(3) 2 3 4 5 NAME 6 curl_easy_perform - perform a blocking file transfer 7 8 SYNOPSIS 9 #include <curl/curl.h> 10 11 CURLcode curl_easy_perform(CURL *easy_handle); 12 13 DESCRIPTION 14 Invoke this function after curl_easy_init(3) and all the curl_easy_setopt(3) calls are made, and will perform the transfer as 15 described in the options. It must be called with the same easy_handle as input as the curl_easy_init(3) call returned. 16 17 curl_easy_perform(3) performs the entire request in a blocking manner and returns when done, or if it failed. For non-blocking behav‐ 18 ior, see curl_multi_perform(3). 19 20 You can do any amount of calls to curl_easy_perform(3) while using the same easy_handle. If you intend to transfer more than one 21 file, you are even encouraged to do so. libcurl will then attempt to re-use the same connection for the following transfers, thus 22 making the operations faster, less CPU intense and using less network resources. Just note that you will have to use 23 curl_easy_setopt(3) between the invokes to set options for the following curl_easy_perform. 24 25 You must never call this function simultaneously from two places using the same easy_handle. Let the function return first before 26 invoking it another time. If you want parallel transfers, you must use several curl easy_handles. 27 28 While the easy_handle is added to a multi handle, it cannot be used by curl_easy_perform(3). 29 30 RETURN VALUE 31 CURLE_OK (0) means everything was ok, non-zero means an error occurred as <curl/curl.h> defines - see libcurl-errors(3). If the CUR‐ 32 LOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3) there will be a readable error message in the error buffer when non-zero is 33 returned. 34 35 EXAMPLE 36 CURL *curl = curl_easy_init(); 37 if(curl) { 38 CURLcode res; 39 curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); 40 res = curl_easy_perform(curl); 41 curl_easy_cleanup(curl); 42 } 43 44 SEE ALSO 45 curl_easy_init(3), curl_easy_setopt(3), curl_multi_add_handle(3), curl_multi_perform(3), libcurl-errors(3), 46 47 48 49 50 libcurl 7.7 5 Mar 2001 curl_easy_perform(3)