CURL.PerformAsync
-----------------

Perform a curl transfer asynchronously.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [CURL](component_CURL.md) | [5.2](newinversion52.md) | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes |

MBS( "CURL.PerformAsync"; curl ) 

**MBS**( **"CURL.PerformAsync";** /\* Perform a curl transfer asynchronously. \*/  
**$curl**) /\* The CURL session handle. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| curl | The CURL session handle. | $curl |

### Result

Returns OK or error.

### Description

Perform a curl transfer asynchronously.  
The query is enqueued and run by the plugin in background.  
When transfer is finished, a script is triggered if you set one with [CURL.SetFinishedScript](CURLSetFinishedScript.md) function.  
This function is called after the init and all the options are set, and will perform the transfer as described in the options. It must be called with the same handle as input as the [CURL.New](CURLNew.md) call returned.  
  
You can do any amount of calls to [CURL.Perform](CURLPerform.md) while using the same handle. If you intend to transfer more than one file, you are even encouraged to do so. CURL will then attempt to re-use the same connection for the following transfers, thus making the operations faster, less CPU intense and using less network resources. Just note that you will have to use the option functions between the invokes to set options for the following [CURL.Perform](CURLPerform.md).  
  
While transfer is running, your FileMaker application is not blocked. It's useful to show progress with using [CURL.SetUpdateProgressDialog](CURLSetUpdateProgressDialog.md). Be aware that transfer runs in background and you should query status with functions like [CURL.IsRunning](CURLIsRunning.md), [CURL.GetProgressTotalDownload](CURLGetProgressTotalDownload.md), [CURL.GetProgressTotalUpload](CURLGetProgressTotalUpload.md), [CURL.GetProgressCurrentDownload](CURLGetProgressCurrentDownload.md) and [CURL.GetProgressCurrentUpload](CURLGetProgressCurrentUpload.md).  
  
Internal buffer for output, debug and header data is cleared before the perform.  
  
We run the transfer on the main thread and continue processing when FileMaker is idle. Transfers can timeout when a dialog blocks processing for a minute. Async is more efficient with lots of transfers compared to [CURL.PerformInBackground](CURLPerformInBackground.md), but the later can run when dialogs are open. Please use [CURL.PerformInBackground](CURLPerformInBackground.md) on server side scripts.  
  
Version 14.0 enables this function for server use in a limited environment. You need to loop and make script pauses for the transfers to run. This runs all asynchronous transfers together while a pause happens, while [CURL.PerformInBackground](CURLPerformInBackground.md) has a thread per request to do it independent in background. Server side we do not trigger scripts to notify about finished state or progress.  
### Examples

Start a few transfers:

 Go to Record/Request/Page \[First\]  
Loop  
 Set Variable \[$curl ; Value:MBS ("[CURL.New](CURLNew.md)")\]  
 Set Variable \[$r ; Value:MBS ("[CURL.SetFinishedScript](CURLSetFinishedScript.md)"; $curl ; Get(FileName); "DownloadFinished")\]  
 Set Variable \[$r ; Value:MBS ("[CURL.SetProgressScript](CURLSetProgressScript.md)"; $curl ; Get(FileName); "ProgressScript")\]  
 Set Variable \[$r ; Value:MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; Download Async::URL )\]  
 Set Variable \[$r ; Value:MBS ("[CURL.SetTag](CURLSetTag.md)"; $curl ; Get(RecordID))\]  
 Set Field \[Download Async::Progress ; 0\]  
 Set Field \[Download Async::CURL Handle; $curl \]  
 Set Variable \[$r ; Value:MBS ("CURL.PerformAsync"; $curl )\]  
 If \[MBS ("IsError")\]  
 Show Custom Dialog \["CURL Error"; $r \]  
 End If  
 Commit Records/Requests \[Skip data entry validation; No dialog\]  
 Go to Record/Request/Page \[Next; Exit after last\]  
End Loop  
### See also

- [CURL.SetMultiOptionMaxConcurrentStreams](CURLSetMultiOptionMaxConcurrentStreams.md)
- [CURL.SetMultiOptionMaxConnects](CURLSetMultiOptionMaxConnects.md)
- [CURL.SetMultiOptionMaxHostConnections](CURLSetMultiOptionMaxHostConnections.md)
- [CURL.SetMultiOptionMaxTotalConnections](CURLSetMultiOptionMaxTotalConnections.md)
- [CURL.SetMultiOptionPipelining](CURLSetMultiOptionPipelining.md)
- [CURL.SetOptionURL](CURLSetOptionURL.md)
- [CURL.SetProgressScript](CURLSetProgressScript.md)
- [CURL.SetSucceededEvaluate](CURLSetSucceededEvaluate.md)
- [CURL.SetSucceededScript](CURLSetSucceededScript.md)
- [CURL.SetUpdateProgressDialog](CURLSetUpdateProgressDialog.md)

### Release notes

- **Version 15.0**
    - Changed functions returning CURL errors to mark this as error, so [IsError](https://www.mbsplugins.eu/IsError.shtml) function returns true. This affects [CURL.Perform](https://www.mbsplugins.eu/CURLPerform.shtml), [CURL.FormClear](https://www.mbsplugins.eu/CURLFormClear.shtml), [CURL.FormFinish](https://www.mbsplugins.eu/CURLFormFinish.shtml), [CURL.Upkeep](https://www.mbsplugins.eu/CURLUpkeep.shtml), [CURL.SendText](https://www.mbsplugins.eu/CURLSendText.shtml), [CURL.SendData](https://www.mbsplugins.eu/CURLSendData.shtml), [CURL.PerformAsync](https://www.mbsplugins.eu/CURLPerformAsync.shtml), [CURL.WebSocketSend](https://www.mbsplugins.eu/CURLWebSocketSend.shtml), [CURL.WebSocketReceive](https://www.mbsplugins.eu/CURLWebSocketReceive.shtml), CURL.SetSocketNonBlocking, CURL.SetSocketNonBlocking, [SendMail.PrepareCURL](https://www.mbsplugins.eu/SendMailPrepareCURL.shtml) and various CURL.SetOption functions.

### Example Databases

- [CURL/Download Async](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Download%20Async.shtml#1ScriptAnchor_)
- [CURL/MQTT](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/MQTT.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 15.0pr9](https://www.mbsplugins.de/archive/2025-01-10/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MQTT in FileMaker](https://www.mbsplugins.de/archive/2024-06-25/MQTT_in_FileMaker/monkeybreadsoftware_blog_filemaker)
- [Parallel network transfers with MBS Plugin](https://www.mbsplugins.de/archive/2023-12-18/Parallel_network_transfers_wit/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 5.2 for OS X/Windows - More than 3200 Functions](https://www.mbsplugins.de/archive/2015-08-04/MBS_FileMaker_Plugin_52_for_OS/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 2/2024, Seite 17 bis 18](https://filemaker-magazin.de/neuigkeit/4257-Appetithappen-FMM_202402)

This function checks for a license.

Created 12nd July 2015 , last changed 21st December 2023

  
[CURL.Perform](CURLPerform.md) - [CURL.PerformInBackground](CURLPerformInBackground.md)

[HTML Version](CURLPerformAsync.shtml)