-
-
Notifications
You must be signed in to change notification settings - Fork 11
libcURL.MultiHandle
libcURL.MultiHandle
Protected Class MultiHandle
Inherits libcURL.cURLHandle
This class wraps the curl_multi API. A curl_multi "stack" can manage one or more
EasyHandles
, with each EasyHandle
corresponding to a single transfer. Once all desired transfers have been added, you may call MultiHandle.Perform
(instead of EasyHandle.Perform
) to begin the transfer(s).
Calling MultiHandle.Perform
asynchronously performs all of the transfers in the multistack until
they complete, error out, or are explicitly removed. Calling MultiHandle.PerformOnce
synchronously performs a portion of the transfers on the calling thread. In both cases transfers are automatically removed when they finish or error out.
EasyHandles
may be added and removed at any point during a transfer. Once added, the MultiHandle
will maintain a (RB) reference to the EasyHandle
until it is removed (either explicitly or automatically).
An EasyHandle
added to a multistack will behave exactly as it would had it not been added, including raising
events in response to libcURL callback functions, but without blocking the thread.
Using a multistack allows single-threaded apps (like RB apps) to use libcURL in a non-blocking manner.
- AddTransfer
- Close
- Constructor
- Count
- Destructor
- Handle
- HasTransfer
- LastError
- Operator_Compare
- Pause
- Perform
- PerformOnce
- QueryInterval
- RemoveTransfer
- SetOption
This example creates two instances of EasyHandle and then adds both of them to a MultiHandle:
Dim multi As New libcURL.MultiHandle
Dim easy1 As New libcURL.EasyHandle
Dim easy2 As New libcURL.EasyHandle
easy1.URL = "www.example.com/file.html"
easy2.URL = "www.example.com/image.png"
Dim mb1 As New MemoryBlock(0)
Dim b1 As New BinaryStream(mb1)
easy1.DownloadStream = b1
Dim mb2 As New MemoryBlock(0)
Dim b2 As New BinaryStream(mb2)
easy2.DownloadStream = b2
multi.AddTransfer(easy1)
multi.AddTransfer(easy2)
Do Until Not multi.PerformOnce()
App.YieldToNextThread
Loop
b1.Close
b2.Close
Wiki home | Project page | Bugs | Become a sponsor
Text and code examples are Copyright ©2014-24 Andrew Lambert, offered under the CC BY-SA 3.0 License.