Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
9.5
10.0
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
Statistic
FMM
Blog
CURL.ReceiveData
Receives raw data on a connection.
Component |
Version |
macOS |
Windows |
Linux |
Server |
iOS SDK |
CURL
|
7.2 |
✅ Yes
|
✅ Yes
|
✅ Yes
|
✅ Yes
|
✅ Yes
|
MBS( "CURL.ReceiveData"; curl; BytesToRead { ; ResultType } )
More
MBS(
"CURL.ReceiveData"; /* Receives raw data on a connection. */
$curl; /* The CURL session handle. */
$BytesToRead; /* Maximum number of bytes to read.e.g. 1000 */
$ResultType) /* Optional; What type of data to return.
Can be hex or base64. Default is hex.
Added Base64URL as option for plugin version 10.3.e.g. "hex" */
Less
Parameters
Parameter |
Description |
Example |
Flags |
curl |
The CURL session handle. |
$curl |
|
BytesToRead |
Maximum number of bytes to read. |
1000 |
|
ResultType |
What type of data to return.
Can be hex or base64. Default is hex.
Added Base64URL as option for plugin version 10.3. |
"hex" |
Optional |
Result
Returns OK or error.
Description
Receives raw data on a connection.
This function receives raw data from the established connection. You may use it together with SendData to implement custom protocols using libcurl. This functionality can be particularly useful if you use proxies and/or SSL encryption: libcurl will take care of proxy negotiation and connection set-up.
BytesToRead is the maximum amount of data you want to read now. The function returns the text read, which can be less than requested.
To establish the connection, set OptionConnectOnly = true before calling Perform. Note that ReceiveData does not work on connections that were created without this option.
The call will return CURLE_AGAIN if there is no data to read - the socket is used in non-blocking mode internally. When CURLE_AGAIN is returned, wait for data to arrive.
Wait on the socket only if ReceiveData returns CURLE_AGAIN. The reason for this is libcurl or the SSL library may internally cache some data, therefore you should call ReceiveData until all data is read which would include any cached data.
Furthermore if you wait on the socket and it tells you there is data to read, ReceiveData may return CURLE_AGAIN if the only data that was read was for internal SSL processing, and no other data is available.
On success, sets error code to CURLE_OK (0) and returns the data.
On failure, returns zero and error code is set to the appropriate error code.
The function may return CURLE_AGAIN. In this case, use your operating system facilities to wait until data can be read, and retry.
Reading exactly 0 bytes indicates a closed connection.
If there's no socket available to use from the previous transfer, this function returns CURL_EUNSUPPORTED_PROTOCOL.
Please use CURL.ErrorCode to query error after you used this function.
See also CURL.SendData function to send data and CURL.SetOptionConnectOnly to connect only and use these functions.
See also
Release notes
Blog Entries
Created 27th March 2017, last changed 22nd May 2020
CURL.Protocols
-
CURL.ReceiveText
Feedback: Report problem or ask question.