ServerSocket.SendQuery
----------------------

Sends a query to a Serversocket on another FileMaker instance.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [ServerSocket](component_ServerSocket.md) | [3.2](newinversion32.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

### Deprecated

This function was [deprecated](deprecated.md). Use [WebHook](component_WebHook.md) functions instead.

MBS( "ServerSocket.SendQuery"; Target; Port; Login; Type; Query ) 

**MBS**( **"ServerSocket.SendQuery";** /\* Sends a query to a Serversocket on another FileMaker instance. \*/  
**$Target**; /\* The target IP or name of the server. Can be an IP or a name.e.g. "localhost" \*/   
**$Port**; /\* The network port of the server to use.e.g. 9000 \*/   
**$Login**; /\* The login secret. Server will only answer if the logins match.e.g. "Hello" \*/   
**$Type**; /\* The type of the query. Can be MBSVersion, SQL, Evaluate or Script.e.g. "Evaluate" \*/   
**$Query**) /\* The query to use. Must match the type of query above.   
For Script calls please use filename:scriptname:parameter to run a script and use full file name with extension.e.g. "Get(AccountName)" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Target | The target IP or name of the server. Can be an IP or a name. | "localhost" |
| Port | The network port of the server to use. | 9000 |
| Login | The login secret. Server will only answer if the logins match. | "Hello" |
| Type | The type of the query. Can be MBSVersion, SQL, Evaluate or Script. | "Evaluate" |
| Query | The query to use. Must match the type of query above.    For Script calls please use filename:scriptname:parameter to run a script and use full file name with extension. | "Get(AccountName)" |

### Result

Returns result or error.

### Description

Sends a query to a Serversocket on another FileMaker instance.  
This has nothing to do with a FileMaker Server. The plugin starts a socket which answers queries, so the current FileMaker instance becomes a kind of server.  
See example database for sample queries.  
Queries can be SQL queries, expression evaluation or running scripts.  
While you can send queries across the internet, we recommend to use a VPN connection to do so.  
  
Version 6.3 now supports passing IPv4, iPv6, or a host name.  
### Examples

Query a table with SQL:

 MBS ( "ServerSocket.SendQuery"; "FrontDeskMac.local"; 9000; "mysecret"; "SQL"; "SELECT JobID, Status FROM JobTable" )  
Query the account name of the current user:

 MBS ( "ServerSocket.SendQuery"; "FrontDeskMac.local"; 9000; "mysecret"; "Evaluate"; "Get(AccountName)" )  
Start a script:

 MBS ( "ServerSocket.SendQuery"; "FrontDeskMac.local"; 9000; "mysecret"; "Script"; "OrderDatabase:PrintLastOrder:5" )  
### Release notes

- **Version 8.3**
    - Updated code for [Socket.Connect](http://www.mbsplugins.eu/SocketConnect.shtml), [ServerSocket.SendQuery](http://www.mbsplugins.eu/ServerSocketSendQuery.shtml), [SSH.Connect](http://www.mbsplugins.eu/SSHConnect.shtml) and SendCommand to use new unified socket connection code, which uses IPv4 and IPv6, queries DNS if needed and tries several IPs if needed.

### Example Databases

- [Network/ServerSocket/Send Query](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/ServerSocket/Send%20Query.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 8.3pr3](https://www.mbsplugins.de/archive/2018-06-21/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.3pr4](https://www.mbsplugins.de/archive/2016-06-24/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.0pr5](https://www.mbsplugins.de/archive/2016-01-02/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 5.2pr4](https://www.mbsplugins.de/archive/2015-06-24/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 5.0pr6](https://www.mbsplugins.de/archive/2015-01-06/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 3/2013, Seite 24 bis 25](https://filemaker-magazin.de/neuigkeit/3661-Appetithappen-FMM_201303)

This function checks for a license.

Created 18th August 2014 , last changed 17th October 2021

  
[ServerSocket.GetAllowedTypes](ServerSocketGetAllowedTypes.md) - [ServerSocket.SetAllowedScripts](ServerSocketSetAllowedScripts.md)

[HTML Version](ServerSocketSendQuery.shtml)