文章2:Using The libcurl C Interface(重要)

來源:互聯網
上載者:User
Using The libcurl C Interface

There's the tutorial to start with, read the tutorial to get a general in-depth grip of what libcurl programming is all about.

有一篇概述文章,閱讀 the tutorial可以對於libcurl編程有一個深入的理解。

There are some example C source codes you can check out. They're not all-covering or even very extensive, but they might serve as a source of inspiration to start hacking.

另外,也可以在example C source codes學習libcurl。

Dig into the Symbols In Versions document to learn in which libcurl releases symbols were added or removed.

Windows developers using Microsoft Visual Studio, might enjoy:

  • Andrei Jakab's Using libcurl with SSH support in Visual Studio 2010 [PDF]
  • Rosso Salmanzadeh's Using libcurl in Visual Studio [PDF] guide.
Easy or Multi

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是同步、高效、方便使用的,並且easy interface用於檔案傳輸。大量的應用程式都使用easy interface。

multi interface是非同步,提供了使用單個線程或多線程的多次傳輸。可以閱讀 the multi interface overview來理解multi interface是如何工作的

The Easy interface

When using libcurl you init (libcurl
- curl_global_init())your easy-session and get a handle, which you use as input to the following interface functions you use.

You continue by setting all the options you want in the upcoming transfer, most important among them is the URL itself. You might want to set some callbacks as
well that will be called from the library when data is available etc.

When all is setup, you tell libcurl to perform the transfer. It will then do the entire operation and won't return until it is done or failed.

After the performance is made, you may get information about the transfer and then you cleanup the
easy-session's handle and libcurl is entire off the hook!

在使用libcurl時,首先是初始化你的easy-session(簡單對話)並獲得一個handle,你可以使用這個handle作為接下來所用的介面函數的輸入。

接下來,你設定在upcoming transfer(接下來的傳輸,實際上就是指:接下來的這次串連)中你想要的選項,這些選項中最重要的就是URL。你也可以設定一些用於資料處理的一些回呼函數。

當這些都已經建立以後,你就可以執行這次transfer。它會執行所有操作,知道成功或者失敗才會傳回值。

 

 

See also the easy interface overview.

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:

這些函數時在easy interface總經常用到的函數,還有一系列其他的有用的函數

 

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

All man pages are included in every release archive, in three different formats: man page, HTML and pdf.

所有的說明文檔都包含在每個發行版本裡,有三種形式:man page,HTML和pdf



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.