Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

MBS FileMaker Plugin Example Databases

TCP Receiver

All examples are included with download of MBS FileMaker Plugin.

TCP Receiver.fmp12

Overview
Tables 1
Relationships 0
Layouts 1
Scripts 6
Value Lists 1
Custom Functions 0
Custom Menus 33
File Options
Default custom menu set [Standard FileMaker Menus]
Default theme Minimalistisch
When opening file
Minimum allowed version 12.0
Login using Account Name; Account= Admin
Allow user to save password On
Require iOS passcode Off
Show Sign-in fields Off
Switch to layout Off
Hide all toolbars Off
Script triggers
OnFirstWindowOpen Script: StartScript
OnLastWindowClose Off
OnWindowOpen Off
OnWindowClose Off
OnFileAVPlayerChange Off
OnWindowTransaction Off
Thumbnail Settings
Generate Thumbnails On; Temporary

 

Tables

Table Name
Statistics
Comments
Occurrences in Relationship Graph
TCP Receiver
6 fields defined, 0 record
TCP Receiver

Fields

Table Name: TCP Receiver - 6 Fields
Field Name Type Options Comments On Layouts In Relationships In Scripts In Value Lists
Port Normal, Number Auto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
  • Indexing: None
  • Automatically create indexes as needed
  • Index Language: German
      IP Normal, Text Auto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
      • Indexing: None
      • Automatically create indexes as needed
      • Index Language: German
          Message Normal, Text Auto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
              ListenPort Normal, Number Auto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Global
              • Repetitions: 1
              • Index Language: German
                  Options Normal, Text Auto-Enter:
                  • Allow editing
                  Validation:
                  • Only during data entry
                  Storage:
                  • Global
                  • Repetitions: 1
                  • Index Language: German
                      Status Normal, Text Auto-Enter:
                      • Allow editing
                      Validation:
                      • Only during data entry
                      Storage:
                      • Global
                      • Repetitions: 1
                      • Index Language: German

                          Layout Objects: TCP Receiver

                          Regular Fields

                          Field Name: TCP Receiver::Port
                          Field Properties Coordinates Field Format Field Behavior Quick Find
                          • Top: 111 pt
                          • Left: 138 pt
                          • Bottom: 130 pt
                          • Right: 888 pt
                          • Anchoring: Left and Right, Top
                          Field Format:
                          • Edit Box
                          Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: System Default
                          • Go to next field using: Tab key
                          Yes

                          Field Name: TCP Receiver::IP
                          Field Properties Coordinates Field Format Field Behavior Quick Find
                          • Top: 137 pt
                          • Left: 138 pt
                          • Bottom: 156 pt
                          • Right: 888 pt
                          • Anchoring: Left and Right, Top
                          Field Format:
                          • Edit Box
                          Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: System Default
                          • Go to next field using: Tab key
                          Yes

                          Field Name: TCP Receiver::Message
                          Field Properties Coordinates Field Format Field Behavior Quick Find
                          • Top: 163 pt
                          • Left: 138 pt
                          • Bottom: 182 pt
                          • Right: 888 pt
                          • Anchoring: Left and Right, Top
                          Field Format:
                          • Edit Box
                          Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: System Default
                          • Go to next field using: Tab key
                          Yes

                          Field Name: TCP Receiver::Options
                          Field Properties Coordinates Field Format Field Behavior Quick Find
                          • Top: 34 pt
                          • Left: 138 pt
                          • Bottom: 53 pt
                          • Right: 269 pt
                          • Anchoring: Left, Top
                          Field Format:
                          • Checkbox Set
                          • Display values from: Keep Open
                          Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: Default for Data Type
                          • Go to next field using: Tab key
                          No

                          Field Name: TCP Receiver::ListenPort
                          Field Properties Coordinates Field Format Field Behavior Quick Find
                          • Top: 6 pt
                          • Left: 138 pt
                          • Bottom: 25 pt
                          • Right: 217 pt
                          • Anchoring: Left, Top
                          Field Format:
                          • Edit Box
                          Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: Default for Data Type
                          • Go to next field using: Tab key
                          No

                          Field Name: TCP Receiver::Status
                          Field Properties Coordinates Field Format Field Behavior Quick Find
                          • Top: 74 pt
                          • Left: 366 pt
                          • Bottom: 93 pt
                          • Right: 619 pt
                          • Anchoring: Left, Top
                          Field Format:
                          • Edit Box
                          Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: Default for Data Type
                          • Go to next field using: Tab key
                          No

                          Buttons

                          Button Properties Coordinates Script/Script Step
                            Type:
                          • Text: Close Socket
                          • Top: 69 pt
                          • Left: 766 pt
                          • Bottom: 93 pt
                          • Right: 888 pt
                          • Anchoring: Left, Top
                          Perform Script [ “Close Socket” ]

                          Scripts:


                          Button Properties Coordinates Script/Script Step
                            Type:
                          • Text: Create Socket and Listen
                          • Top: 69 pt
                          • Left: 138 pt
                          • Bottom: 93 pt
                          • Right: 318 pt
                          • Anchoring: Left, Top
                          Perform Script [ “CreateSocket” ]

                          Scripts:


                          Value Lists

                          Value List Name Source Values On Layouts
                          Keep Open Custom
                          • Keep Open

                          Script Hierarchy

                          CreateSocket
                          StartScript
                          ReadSomething
                          NewConnection
                          SocketError
                          Close Socket

                          Next Script: [StartScript]
                          Script Name CreateSocket
                          Run script with full access privileges Off
                          Siri Shortcut Visible Off
                          Include In Menu Yes
                          Layouts that use this script
                          Scripts that use this script
                            Script Definition
                            Script Steps
                            • If [ not (GetAsNumber($$sock) > 0) ]
                            • Set Variable [ $$sock; Value:MBS("Socket.NewTCPSocket") ]
                            • If [ MBS("IsError") ]
                            • Show Custom Dialog [ Title: "Failed to create Socket"; Message: $$sock; Default Button: “OK”, Commit: “No” ]
                            • Set Variable [ $$sock; Value:"" ]
                            • Exit Script [ ]
                            • End If
                            • Set Variable [ $r; Value:MBS("Socket.SetNewConnectionHandler"; $$sock; Get(FileName); "NewConnection") ]
                            • Set Variable [ $r; Value:MBS("Socket.SetErrorHandler"; $$sock; Get(FileName); "SocketError") ]
                            • Set Variable [ $r; Value:MBS("Socket.Listen"; $$sock; TCP Receiver::ListenPort) ]
                            • If [ MBS("IsError") ]
                            • Show Custom Dialog [ Title: "Failed to listen on Socket"; Message: $r; Default Button: “OK”, Commit: “No” ]
                            • Set Variable [ $$sock; Value:"" ]
                            • Exit Script [ ]
                            • Else [ ]
                            • Set Field [ TCP Receiver::Status; "Socket created." ]
                            • End If
                            • End If
                            Fields used in this script
                            Scripts used in this script
                              Layouts used in this script
                                Tables used in this script
                                Table occurrences used by this script
                                Custom Functions used by this script
                                  Custom menu set used by this script

                                    Previous Script: [CreateSocket] Next Script: [ReadSomething]
                                    Script Name StartScript
                                    Run script with full access privileges Off
                                    Siri Shortcut Visible Off
                                    Include In Menu Yes
                                    Layouts that use this script
                                      Scripts that use this script
                                        Script Definition
                                        Script Steps
                                        • Set Field [ TCP Receiver::Status; "" ]
                                        • Delete All Records [ No dialog ]
                                        Fields used in this script
                                        Scripts used in this script
                                          Layouts used in this script
                                            Tables used in this script
                                            Table occurrences used by this script
                                            Custom Functions used by this script
                                              Custom menu set used by this script

                                                Previous Script: [StartScript] Next Script: [NewConnection]
                                                Script Name ReadSomething
                                                Run script with full access privileges Off
                                                Siri Shortcut Visible Off
                                                Include In Menu No
                                                Layouts that use this script
                                                  Scripts that use this script
                                                    Script Definition
                                                    Script Steps
                                                    • Set Variable [ $sock; Value:Get(ScriptParameter) ]
                                                    • Set Variable [ $r; Value:MBS("Socket.Read"; $sock; 1500; "UTF-8") ]
                                                    • Set Variable [ $keepOpen; Value:Length ( TCP Receiver::Options ) > 0 ]
                                                    • If [ Left($r; 5) = "[MBS]" ]
                                                    • Show Custom Dialog [ Title: "Error Reading"; Message: $r; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
                                                    • Else If [ Length($r) = 0 ]
                                                    • // Show Custom Dialog [ Title: "Error Reading"; Message: "No data available."; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
                                                    • Else [ ]
                                                    • New Record/Request
                                                    • Set Field [ TCP Receiver::Message; $r ]
                                                    • Set Field [ TCP Receiver::IP; MBS("Socket.RemoteIP"; $sock) ]
                                                    • Set Field [ TCP Receiver::Port; MBS("Socket.RemotePort"; $sock) ]
                                                    • Set Field [ TCP Receiver::Status; "Socket received " & Get(CurrentHostTimestamp) ]
                                                    • Commit Records/Requests [ No dialog ]
                                                    • End If
                                                    • If [ $keepOpen ]
                                                    • #keep open and send something back
                                                    • Set Variable [ $r; Value:MBS("Socket.Write"; $sock; "Thank you."; "UTF-8") ]
                                                    • Else [ ]
                                                    • #close it
                                                    • Set Variable [ $r; Value:MBS("Socket.Close"; $sock) ]
                                                    • End If
                                                    Fields used in this script
                                                    Scripts used in this script
                                                      Layouts used in this script
                                                        Tables used in this script
                                                        Table occurrences used by this script
                                                        Custom Functions used by this script
                                                          Custom menu set used by this script

                                                            Previous Script: [ReadSomething] Next Script: [SocketError]
                                                            Script Name NewConnection
                                                            Run script with full access privileges Off
                                                            Siri Shortcut Visible Off
                                                            Include In Menu No
                                                            Layouts that use this script
                                                              Scripts that use this script
                                                                Script Definition
                                                                Script Steps
                                                                • Set Variable [ $sock; Value:Get(ScriptParameter) ]
                                                                • Set Variable [ $newSock; Value:MBS("Socket.AcceptNewConnection"; $sock) ]
                                                                • If [ GetAsNumber($newSock) > 0 ]
                                                                • Set Variable [ $r; Value:MBS("Socket.SetErrorHandler"; $newsock; Get(FileName); "SocketError") ]
                                                                • Set Variable [ $r; Value:MBS("Socket.SetDataAvailableHandler"; $newsock; Get(FileName); "ReadSomething") ]
                                                                • Set Field [ TCP Receiver::Status; "Socket accepted connection " & Get(CurrentHostTimestamp) ]
                                                                • End If
                                                                Fields used in this script
                                                                Scripts used in this script
                                                                  Layouts used in this script
                                                                    Tables used in this script
                                                                    Table occurrences used by this script
                                                                    Custom Functions used by this script
                                                                      Custom menu set used by this script

                                                                        Previous Script: [NewConnection] Next Script: [Close Socket]
                                                                        Script Name SocketError
                                                                        Run script with full access privileges Off
                                                                        Siri Shortcut Visible Off
                                                                        Include In Menu No
                                                                        Layouts that use this script
                                                                          Scripts that use this script
                                                                            Script Definition
                                                                            Script Steps
                                                                            • Set Variable [ $sock; Value:Get(ScriptParameter) ]
                                                                            • Show Custom Dialog [ Title: "Socket Error"; Message: "For Socket " & $sock; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
                                                                            • Set Variable [ $r; Value:MBS("Socket.Close"; $sock) ]
                                                                            • Set Variable [ $$sock; Value:"" ]
                                                                            Fields used in this script
                                                                              Scripts used in this script
                                                                                Layouts used in this script
                                                                                  Tables used in this script
                                                                                    Table occurrences used by this script
                                                                                      Custom Functions used by this script
                                                                                        Custom menu set used by this script

                                                                                          Previous Script: [SocketError]
                                                                                          Script Name Close Socket
                                                                                          Run script with full access privileges Off
                                                                                          Siri Shortcut Visible Off
                                                                                          Include In Menu No
                                                                                          Layouts that use this script
                                                                                          Scripts that use this script
                                                                                            Script Definition
                                                                                            Script Steps
                                                                                            • If [ GetAsNumber($$sock) > 0 ]
                                                                                            • Set Variable [ $r; Value:MBS("Socket.Close"; $$sock) ]
                                                                                            • Set Variable [ $$sock; Value:"" ]
                                                                                            • Set Field [ TCP Receiver::Status; "Socket closed." ]
                                                                                            • End If
                                                                                            Fields used in this script
                                                                                            Scripts used in this script
                                                                                              Layouts used in this script
                                                                                                Tables used in this script
                                                                                                Table occurrences used by this script
                                                                                                Custom Functions used by this script
                                                                                                  Custom menu set used by this script

                                                                                                    Download example: TCP Receiver

                                                                                                    Used functions: