Socket.WriteMLLP
----------------

Writes text to the socket.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Socket](component_Socket.md) | [3.1](newinversion31.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Socket.WriteMLLP"; SocketID; Text { ; Encoding } ) 

**MBS**( **"Socket.WriteMLLP";** /\* Writes text to the socket. \*/  
**$SocketID**; /\* The socket ID received by [Socket.Connect](SocketConnect.md) function.e.g. $sock \*/   
**$Text**; /\* The text to send.e.g. "Hello World" \*/   
**$Encoding**) /\* Optional; The text encoding for text parameter.   
Default is native.e.g. "UTF8" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| SocketID | The socket ID received by [Socket.Connect](SocketConnect.md) function. | $sock |  |
| Text | The text to send. | "Hello World" |  |
| Encoding | The text encoding for text parameter.    Default is native.   Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the [FAQ](https://www.monkeybreadsoftware.com/filemaker/faq.shtml). | "UTF8" | Optional |

### Result

Returns the number of bytes written or an error message.

### Description

Writes text to the socket.  
This function wraps the given text into a MLLP packet by adding start and end bytes.  
  
Result is -1 if socket can't write. See [Socket.LastError](SocketLastError.md) for error code.  
Changed in v10.4 to return error if socket is closed or disconnected instead of -1.  
### Examples

Write something:

 MBS ( "Socket.WriteMLLP"; $sock ; "Hello World" )  
Write something with DOS text encoding:

 MBS ( "Socket.WriteMLLP"; $sock ; "Umlauts: äöü"; "DOS" )  
### See also

- [Socket.Connect](SocketConnect.md)
- [Socket.LastError](SocketLastError.md)
- [Socket.Write](SocketWrite.md)
- [Socket.WriteByte](SocketWriteByte.md)
- [Socket.WriteHex](SocketWriteHex.md)

### Blog Entries

- [Socket changes for MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2020-08-31/Socket_changes_for_MBS_FileMak/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 31st August 2020

  
[Socket.WriteHex](SocketWriteHex.md) - [Speech.AttributesForVoices](SpeechAttributesForVoices.md)

[HTML Version](SocketWriteMLLP.shtml)