日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Libcurl筆記一-創(chuàng)新互聯(lián)

一:
1,全局初始化及釋放:
CURLcode curl_global_init(long flags)

創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:做網(wǎng)站、成都網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的利州網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

flags: CURL_GLOBAL_ALL //初始化所有的可能的調(diào)用。

CURL_GLOBAL_SSL //初始化支持 安全套接字層。

CURL_GLOBAL_WIN32 //初始化win32套接字庫。

CURL_GLOBAL_NOTHING //沒有額外的初始化。

這個(gè)函數(shù)只能用一次。(其實(shí)在調(diào)用curl_global_cleanup 函數(shù)后仍然可再用)

如果這個(gè)函數(shù)在curl_easy_init函數(shù)調(diào)用時(shí)還沒調(diào)用,它講由libcurl庫自動(dòng)調(diào)用,所以多線程下最好主動(dòng)調(diào)用該函數(shù)以防止在線程中curl_easy_init時(shí)多次調(diào)用。

注意:雖然libcurl是線程安全的,但curl_global_init是不能保證線程安全的,所以不要在每個(gè)線程中都調(diào)用curl_global_init,應(yīng)該將該函數(shù)的調(diào)用放在主線程中。

void curl_global_cleanup(void)

二:兩種模式
1,
The easy interface is a synchronous, efficient, quickly used and... yes, easy interface for file transfers. Numerous applications have been built using this.
The multi interface is the asynchronous brother in the family and it also offers multiple transfers using a single thread and more. Get a grip of how to work with it in the multi interface overview.

easy interface 同步的快速的,多用于文件傳輸。
multi interface 異步的,支持一個(gè)或多個(gè)線程里面的多個(gè)文件傳輸。

https://curl.haxx.se/libcurl/c/libcurl-easy.html
https://curl.haxx.se/libcurl/c/libcurl-multi.html

三:easy interface
1,初始化下載handle及釋放

CURL *easy_handle =     curl_easy_init();

curl_easy_cleanup(easy_handle);

2,CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);

CURLoption枚舉了curl能做的所有操作。
設(shè)置回調(diào)函數(shù),訪問URL,超時(shí)時(shí)間,斷點(diǎn)續(xù)傳等。

3,CURLcode curl_easy_perform(CURL * easy_handle );
前面初始化init,屬性steopt設(shè)置好后就調(diào)perform開始執(zhí)行起來。

4,easy interface常用的函數(shù)
curl_easy_init()
curl_easy_cleanup()
curl_easy_setopt()
curl_easy_perform()
curl_easy_getinfo()

While the above functions are the main functions to use in the easy interface, there is a series of other helpful functions too including:

curl_version()

returns a pointer to the libcurl version string

curl_getdate()

converts a date string to time_t

curl_formadd()

build multipart form-data posts

curl_formfree()

free a previously built form POST

curl_slist_append()

builds a linked list

curl_slist_free_all()

frees a whole curl_slist as made with curl_slist_append()

curl_easy_escape()

URL encodes a string

curl_easy_unescape()

URL decodes a string

5,
問題:
1>MCurl.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function _main

1>MCurl.obj : error LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function _main

解決:
1,C/C++->Preprocessor->Definitions 增加:
BUILDING_LIBCURL HTTP_ONLY或 CURL_STATICLIB CURL_DISABLE_LDAP

2,附加ws2_32.lib和wldap32.lib

6,
上面配置release下沒問題,dubug下會(huì)報(bào)啟動(dòng)錯(cuò)誤!

7,debug下的一些問題
問題:

解決:
上面提示already defined in LIBCMTD,去熟悉里面設(shè)置忽略LIBCMTD
下面根據(jù)列出缺少的函數(shù)名在MSDN搜對應(yīng)的lib添加上

問題:
編譯通過了但是啟動(dòng)失敗

解決:
去查下提示的manifest文件

左邊的debug的,右邊是release的,按照右邊吧762移到6195上面去。(因?yàn)閞elase啟動(dòng)沒問題所以我以726版本為準(zhǔn))

Generate Manifest設(shè)為NO防止重編譯又把手動(dòng)修改后的manifest改回去。

啟動(dòng)提示缺MSVCR80D.dll,下載一個(gè)加上。

然后啟動(dòng),運(yùn)行庫崩潰,算了先用release,libcurld.lib可能有問題后面再編一個(gè)。

8,
https://curl.haxx.se/libcurl/c/example.html
官網(wǎng)提供的列子自己編譯運(yùn)行看下。


當(dāng)前名稱:Libcurl筆記一-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://www.dlmjj.cn/article/csjege.html