Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 7.1   7.2   7.3   7.4   7.5   8.0   8.1   8.2   8.3   8.4    Statistic  

Socket.SendMessage

Sends an UDP data message.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Socket 3.1 Yes Yes Yes Yes Yes

MBS( "Socket.SendMessage"; SocketID; IP; Port; Text { ; Encoding } )

Parameters

Parameter Description Example value
SocketID The socket ID received by Socket.Connect function. $sock
IP The target IP or name. "192.168.2.10"
Port The target port to send to. 9000
Text The text to send. "Hello World"
Encoding Optional
The text encoding for text parameter.
Default is native.
Possible encoding names: ANSI, Arabic-Mac, Arabic-Win, Baltic-Win, CentralEurope-Mac, ChineseSimp-Mac, ChineseSimp-Win, ChineseTrad-Mac, ChineseTrad-Win, Cyrillic-Mac, Cyrillic-Win, EasternEurope-Win, Greek-Mac, Greek-Win, Hebrew-Mac, Hebrew-Win, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-15, Korean-Johab, Korean-Mac, Korean-Win, Latin1, Mac, Native, ShiftJIS-Mac, ShiftJIS-Win, Turkish-Mac, Turkish-Win, UTF-8, DOS or Windows. Pass native to use the native encoding of the current platform.
"UTF8"

Result

Returns the number of bytes written or an error message.

Description

Sends an UDP data message.

Examples

Write something:

MBS( "Socket.SendMessage"; $sock; "Hello World" )

Write something with DOS text encoding:

MBS( "Socket.SendMessage"; $sock; "Umlauts: äöü"; "DOS" )

Send UDP Package:

Set Variable [$r; Value:MBS("Socket.SendMessage"; $$sock; UDP Broadcast::BroadcastAddress; UDP Broadcast::Port; UDP Broadcast::Message To Send; "UTF-8")]
If [GetAsNumber($r) = 0]
    Set Field [UDP Broadcast::Send Result; "Failed to Send: "&$r]
Else
    Set Field [UDP Broadcast::Send Result; "Sent "&$r&" Bytes."]
End If

Opens stream to Midi device and plays notes with time offsets:

Set Variable [$DeviceName; Value:"Your device name"]
If [$$stream = ""]
    Set Variable [$$stream; Value:MBS("PortMidi.OpenOutput"; $DeviceName; 100; 10)]
    If [MBS("ISError")]
        Show Custom Dialog ["Failed to open Device"; $$stream]
    End If
End If
#Send notes
Set Variable [$ts; Value:MBS( "PortMidi.TimeStamp" )]
Set Variable [$r; Value:MBS("PortMidi.SendMessage"; $$stream; 144; 48; 95; $ts )]
Set Variable [$r; Value:MBS("PortMidi.SendMessage"; $$stream; 128; 48; 0; $ts + 500 )]
Set Variable [$r; Value:MBS("PortMidi.SendMessage"; $$stream; 144; 50; 95; $ts + 1000 )]
Set Variable [$r; Value:MBS("PortMidi.SendMessage"; $$stream; 128; 50; 0; $ts + 1500 )]
Set Variable [$r; Value:MBS("PortMidi.SendMessage"; $$stream; 144; 52; 95; $ts + 2000 )]
Set Variable [$r; Value:MBS("PortMidi.SendMessage"; $$stream; 128; 52; 0; $ts + 2500 )]

See also

Example Databases

Created 18th August 2014, last changed 23th January 2017


Socket.SSL.UsePrivateKeyFile   -   Socket.SendMessageHex

Feedback: Report problem or ask question.




Links
MBS Xojo PDF Plugins