tCurlMulti

The tCurlMulti class provides an object-oriented wrapper around libcurl's curl_multi functionality.
Using this interface, it is possible to perform several tCurl transfers at the same time, within a single program or thread.

Note: In addition to the properties and methods shown below, tCurlMulti also inherits the background threading capabilities of tCurlBase

tCurlMulti methods and properties:
constructor Create(aOwner:tComponent);
_______________________________________


Creates a new instance of the tCurlMulti object, and initializes the curl_multi_init() library interface.

destructor Destroy;
____________________


Frees the the memory allocated to the tCurlMulti object,
and calls the curl_multi_cleanup() library interface.

This might also destroy the individual tCurl objects contained in the list,
depending on the setting of the PreserveObjects property.

procedure Perform;
___________________


Performs the transfers for each of the tCurl objects in the list.


procedure AddObject(aCurl:tCurl);
__________________________________


Adds your tCurl object to the list of objects that tCurlMulti will act upon.
You can call AddObject repeatedly for each tCurl you want to add.

You should create and set up each tCurl as you normally would, with the exception
that you will call tCurlMulti.Perform instead of tCurl.Perform.

Note that a tCurl cannot "belong" to more than one tCurlMulti at a time, it will be
automatically detached from the previous tCurlMulti if you add it to a new one.

procedure DetachObject(aCurl:tCurl);
_____________________________________


Removes the specified tCurl object from the list of objects that tCurlMulti will act upon,
but does not destroy the tCurl object.

Note that if you call tCurl.Free on an object, it will be detached automatically,
it is not necessary to explicitly detach it first.

procedure Clear;
_________________


Removes all tCurl objects from tCurlMulti's list.

This might also destroy the individual tCurl objects contained in the list,
depending on the setting of the PreserveObjects property.

function IndexOfObject(aCurl:tCurl):LongInt;
_____________________________________________


Returns the zero-based position of the specified tCurl object within the tCurlMulti list,
or (-1) if the object is not found in the list.

property Objects[n:integer]:tCurl;
___________________________________


Returns the tCurl object at list position n.
Note that if the specified index is out-of-bounds, no error is generated, but the property will return NIL.

property Count:LongInt;
________________________


Returns the total number of tCurl objects in the tCurlMulti list.

property OnSingleDone:tCurlMultiSingleDoneEvent;
_________________________________________________


If assigned, this event handler will be called once for each time a tCurl completes (or fails) its transfer.

The Sender parameter will be set to the tCurlMulti that fired the event,
and the which parameter will point to the tCurl object that completed.

If the PreserveObjects property is set to FALSE, the tCurl object will be automatically destroyed
immediately after the event handler returns, otherwise, you can safely detach or free the object yourself
from within this event handler, if you want to.

Note that the OnSingleDone and SingleDoneCallback properties are mutually exclusive,
that is, setting one will unset the other.

property SingleDoneCallback:tCurlMultiSingleDoneCallback;
__________________________________________________________


C-style callback that will be called during tCurlMulti.Perform,
once for each time a tCurl completes (or fails) its transfer.

You callback should match this prototype:
  tCurlMultiSingleDoneCallback =
    procedure(which:tCurl; UserData:pointer); cdecl;


The which parameter will be set to the specific tCurl object which has just completed its transfer,
and the UserData pointer will be the same one as set by the tCurlMulti.DoneData property.

If the PreserveObjects property is set to FALSE, the tCurl object will be destroyed
immediately after your callback returns, otherwise, you can safely detach or free
the object yourself from within the callback, if you want to.

Note that the SingleDoneCallback and OnSingleDone properties are mutually exclusive,
that is, setting one will unset the other.

property DoneData:pointer;
___________________________


A pointer to anything you want, this will be passed as the UserData pointer in the tCurlMulti.SingleDoneCallback.

property SelectTime:LongInt;
_____________________________


The amount of time, in milliseconds, that the tCurlMulti.Perform procedure will spend
waiting on data during each call to the system's select() function.

There should be no need to change this value, unless you know a good reason to do so.

property PreserveObjects:boolean;
__________________________________


If set to TRUE, the tCurlMulti will not try to destroy any of the tCurl objects in its list.

If set to FALSE, tCurlMulti will destroy its tCurl objects under any of the following conditions:
  • A transfer has been completed (whether or not it succeeded).
  • The tCurlMulti.Clear procedure is called.
  • The tCurlMulti object itself is destroyed.
By changing the value of this property during various stages of your application,
in combination with the DetachObject procedure and OnSingleDone event,
you should be able to control whatever deallocation of objects your program requires.

( The default value is False )



Support This Project  
Get CurlPas and TidyPas at SourceForge.net. Fast, secure and Free Open Source software downloads