CURL.WebSocketSend
------------------

Send the specific message fragment over an established WebSocket connection.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [CURL](component_CURL.md) | [13.0](newinversion130.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "CURL.WebSocketSend"; curl; Text { ; Encoding; FrameSize; SendFlags } ) 

**MBS**( **"CURL.WebSocketSend";** /\* Send the specific message fragment over an established WebSocket connection. \*/  
**$curl**; /\* The CURL session handle. \*/   
**$Text**; /\* The post data.e.g. "" \*/   
**$Encoding**; /\* Optional; The text encoding for text parameter.   
Default is UTF-8.e.g. "UTF8" \*/   
**$FrameSize**; /\* Optional; The frame size.  
Default is zero.e.g. 0 \*/   
**$SendFlags**) /\* Optional; The send flags.  
Default is zero.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| curl | The CURL session handle. | $curl |  |
| Text | The post data. | "" |  |
| Encoding | The text encoding for text parameter.    Default is UTF-8. | "UTF8" | Optional |
| FrameSize | The frame size.   Default is zero. | 0 | Optional |
| SendFlags | The send flags.   Default is zero. | 0 | Optional |

### Result

Returns number or error.

### Description

Send the specific message fragment over an established WebSocket connection.  
The text parameter holds the data to send.  
  
Returns the number of payload bytes actually sent.  
  
To send a (huge) fragment using multiple calls with partial content per invoke, set the offset flag (32) in the flags and the FrameSize argument as the total expected size for the first part, then set the offset flag (32) with a zero FrameSize for the following parts.  
  
If not sending a partial fragment or if this is raw mode, FrameSize should be set to zero.  
  
If kWebSocketRaw is enabled in WebSocketOptions, the flags argument should be set to 0.  
### Examples

Test web socket:

 # Start new session   
Set Variable \[ $curl ; Value: MBS ("[CURL.New](CURLNew.md)") \]   
\# put in your web service test URL:   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; "ws://yourserver.com/echo“) \]   
\# connect only with short timeout   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionConnectionTimeout](CURLSetOptionConnectionTimeout.md)"; $curl ; 5) \]   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionConnectOnly](CURLSetOptionConnectOnly.md)"; $curl ; 2) \]   
\# Do connection setup   
Set Variable \[ $result ; Value: MBS ("[CURL.Perform](CURLPerform.md)"; $curl ) \]   
Set Field \[ CURL Test::Result ; $result \]   
\# Check result   
Set Field \[ CURL Test::Text ; MBS ("[CURL.GetResultAsText](CURLGetResultAsText.md)"; $curl ; "UTF8") \]   
Set Field \[ CURL Test::debug ; MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl ) \]   
If \[ $result = "OK" \]   
 # send something  
 Set Variable \[ $result ; Value: MBS ("CURL.WebSocketSend"; $curl ; "Hello World") \]   
 # receive answer  
 Set Field \[ CURL Test::header ; MBS ("[CURL.WebSocketReceive](CURLWebSocketReceive.md)"; $curl ) \]   
End If  
\# Cleanup   
Set Variable \[ $result ; Value: MBS ("[CURL.Release](CURLRelease.md)"; $curl ) \]  
### See also

- [CURL.GetDebugMessages](CURLGetDebugMessages.md)
- [CURL.GetResultAsText](CURLGetResultAsText.md)
- [CURL.New](CURLNew.md)
- [CURL.Perform](CURLPerform.md)
- [CURL.Release](CURLRelease.md)
- [CURL.SetOptionConnectionTimeout](CURLSetOptionConnectionTimeout.md)
- [CURL.SetOptionConnectOnly](CURLSetOptionConnectOnly.md)
- [CURL.SetOptionURL](CURLSetOptionURL.md)
- [CURL.SetOptionWebSocketOptions](CURLSetOptionWebSocketOptions.md)
- [CURL.WebSocketReceive](CURLWebSocketReceive.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.
- **Version 13.0**
    - Added [CURL.SetOptionWebSocketOptions](https://www.mbsplugins.eu/CURLSetOptionWebSocketOptions.shtml), [CURL.WebSocketReceive](https://www.mbsplugins.eu/CURLWebSocketReceive.shtml) and [CURL.WebSocketSend](https://www.mbsplugins.eu/CURLWebSocketSend.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin, version 15.0pr9](https://www.mbsplugins.de/archive/2025-01-10/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [New in MBS FileMaker Plugin 13.0](https://www.mbsplugins.de/archive/2023-01-24/New_in_MBS_FileMaker_Plugin_13/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 13.0 für Claris FileMaker](https://www.mbsplugins.de/archive/2023-01-17/Neues_MBS_Plugin_130_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 13.0 for Claris FileMaker](https://www.mbsplugins.de/archive/2023-01-17/MBS_Plugin_130_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.6pr3](https://www.mbsplugins.de/archive/2022-12-13/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 11st December 2022 , last changed 3th January 2023

  
[CURL.WebSocketReceive](CURLWebSocketReceive.md) - [Calendar.Alarm.Duplicate](CalendarAlarmDuplicate.md)

[HTML Version](CURLWebSocketSend.shtml)