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.3
9.4
9.5
10.0
10.1
10.2
10.3
10.4
10.5
10.6
Statistic
FMM
Blog
Socket.WriteHex
Writes text to the socket.
| Component | Version | macOS | Windows | Linux | Server | FileMaker iOS SDK |
| Socket | 3.1 | Yes | Yes | Yes | Yes | Yes |
Parameters
| Parameter | Description | Example |
|---|---|---|
| SocketID | The socket ID received by Socket.Connect function. | $sock |
| Text | The text to send in hex encoding. | "48656C6C6F" |
Result
Returns the number of bytes written or an error message.
Description
Writes text to the socket.You pass the text hex encoded. For example for "Hello" you pass "48656C6C6F".
Result is -1 if socket can't write. See Socket.LastError for error code.
Changed in v10.4 to return error if socket is closed or disconnected instead of -1.
Examples
Write some text:
MBS( "Socket.WriteHex"; $sock; "48656C6C6F" )
Send some command:
// sends
// <STX><6><CMD_ON><channels><CHECKSUM><ETX>
// In Hex : 0x02 0x06 0x4f 0x07 0xa2 0x03
MBS( "Socket.WriteHex"; $sock; "02064F07A203" )
Connect to IP and send command and wait for answer:
Set Variable [$sock; Value:MBS("Socket.Connect";test::IP; 16128)]
If [MBS("IsError")]
Show Custom Dialog ["Failed to connect"]
Else
Set Variable [$write; Value:MBS("Socket.WriteHex"; $sock; test::query)]
Pause/Resume Script [Duration (seconds): 1]
Set Field [test::response; MBS("Socket.ReadHex"; $sock; 20)]
Show Custom Dialog ["Hex: " & test::response & ¶ & "Text: " & MBS( "Text.DecodeFromHex"; test::response)]
Set Variable [$sock; Value:MBS("Socket.Close"; $sock)]
End If
See also
- IsError
- Socket.Close
- Socket.Connect
- Socket.LastError
- Socket.Read
- Socket.ReadHex
- Socket.Write
- Socket.WriteByte
- Socket.WriteMLLP
- Text.DecodeFromHex
Blog Entries
Created 18th August 2014, last changed 31st August 2020
Socket.WriteByte - Socket.WriteMLLP
Feedback: Report problem or ask question.
Links
MBS Xojo PDF Plugins