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: 11.4   11.5   12.0   12.1   12.2   12.3   12.4   12.5   13.0   13.1    Statistic    FMM    Blog  

CURL.WebSocketReceive

Receive WebSocket data.

Component Version macOS Windows Linux Server iOS SDK
CURL 13.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "CURL.WebSocketReceive"; curl { ; BufferSize } )   More

Parameters

Parameter Description Example Flags
curl The CURL session handle. $curl
BufferSize The buffer size to use.
Default is 65536 and minimum is 1024.
Optional

Result

Returns JSON or error.

Description

Receive WebSocket data.
Retrieves as much as possible of a received WebSocket data fragment into the buffer, but not more than BufferSize bytes. The bytesReceived value in the returned JSON is set to the number of bytes actually stored.

If there is more fragment data to deliver than what fits in the provided buffer, CURL returns a full buffer and the application needs to call this function again to continue draining the buffer.

The returned JSON contains the data and the metadata about the received data.
This includes the following fields:

OffsetThe offset of this data into the frame.
BytesLeftNumber of pending bytes left of the payload.
BytesReceivedThe number of bytes received.
FlagsFlags for this packet.
FlagTextTrue, if this is text.
FlagBinaryTrue, if this is binary.
FlagContinueTrue, if this is not the final fragment of the message, which implies that there will be another fragment coming as part of the same message where this bit is not set.
FlagCloseTrue, if this closes the transfer.
FlagPingTrue, if this is a ping.
FlagPongTrue, if this is a pong.
FlagOffsetTrue, if this is a partial fragment.
DataThe data received, hex encoded.
TextThe data read as UTF-8 text, if possible.

Examples

Read websocket:

Set Variable [ $result ; Value: MBS("CURL.WebSocketReceive"; $curl) ]

Example result:
{ "Offset": 11, "BytesLeft": 0, "BytesReceived": 11, "Flags": 2, "FlagText": false, "FlagBinary": true, "FlagContinue": false, "FlagClose": false, "FlagPing": false, "FlagPong": false, "FlagOffset": false, "Data": "48656C6C6F20576F726C64", "Text": "Hello World" }

See also

Release notes

Blog Entries

This function checks for a paid license.

Created 11st December 2022, last changed 11st December 2022


CURL.Version - CURL.WebSocketSend

💬 Ask a question or report a problem


Start Chat