Lasso Soft Inc. > Home

[ curl_easy_cleanup ]

Method

[curl_easy_cleanup] ends a libcurl easy session.

It must be the last method to call for an easy session. It is the opposite of the [curl_easy_init] method and must be called with the same [curltoken] as input that the [curl_easy_init] call returned.

This will effectively close all connections this [curltoken] has used and possibly has kept open until now. Don't call this function if you intend to transfer more files.

Any uses of the [curltoken] after this function has been called are illegal. This kills the [curltoken] and all memory associated with it!

  • Syntax
curl_easy_cleanup('curltoken')
Examples
  • Intermediate

To obtain the status codes for multiple URLs

Code

local(ctoken, err, data, headerBytes = bytes, bodyBytes = bytes, ready = false)
local(urllist = array('http://www.lassosoft.com/', 'http://downloads.lassosoft.com/', 'ftp://ftp.lassosoft.com'))
local(results = array)
iterate(#urllist, local('url'))
     #ctoken = curl_easy_init
     #err = curl_easy_setopt(#ctoken, curlopt_url, "http://www.lassosoft.com/")
     while(!#ready) => {
          #data = curl_multi_perform(#ctoken)
          #data->second->isa(::bytes) ? #headerBytes->append(#data->second)
          #data->last->isa(::bytes) ? #bodyBytes->append(#data->last)
          #ready = !#data->first
          !#ready ? sleep(10)
     }
     curl_easy_cleanup(#ctoken)
     #results->insert(#headerBytes->split('\r\n')->first)
/iterate
//#headerBytes contains the http headers returned
//#bodyBytes contains the data returned from the request

#results     //shows the status messages from each URL request

Result

array(HTTP/1.1 200 OK, HTTP/1.1 200 OK, HTTP/1.1 200 OK)

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft