Socket.Close
------------

Closes a socket.

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

MBS( "Socket.Close"; SocketID ) 

**MBS**( **"Socket.Close";** /\* Closes a socket. \*/  
**$SocketID**) /\* The socket ID received by [Socket.Connect](SocketConnect.md) function.e.g. $sock \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| SocketID | The socket ID received by [Socket.Connect](SocketConnect.md) function. | $sock |

### Result

Returns OK or error message.

### Description

Closes a socket.  
### Examples

Disconnect socket:

 If \[IsEmpty($$sock )\]  
Else  
 Set Variable \[$r ; Value:MBS ("Socket.Close"; $$Sock )\]  
 Set Variable \[$$Sock ; Value:""\]  
End If  
### See also

- [Socket.CloseAll](SocketCloseAll.md)
- [Socket.Connect](SocketConnect.md)
- [Socket.IsClosed](SocketIsClosed.md)
- [Socket.LocalIP](SocketLocalIP.md)
- [Socket.LocalPort](SocketLocalPort.md)
- [Socket.Read](SocketRead.md)
- [Socket.SetReceiveBufferSize](SocketSetReceiveBufferSize.md)
- [Socket.SetSendBufferSize](SocketSetSendBufferSize.md)
- [Socket.Write](SocketWrite.md)
- [Socket.WriteHex](SocketWriteHex.md)

### Example Databases

- [Network/HTTP Server hosted](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/HTTP%20Server%20hosted.shtml#1ScriptAnchor_)
- [Network/HTTP Server local](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/HTTP%20Server%20local.shtml#2ScriptAnchor_)
- [Network/Socket Test/Socket Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/Socket%20Test/Socket%20Test.shtml#2ScriptAnchor_)
- [Network/SSL/TCP Sender SSL](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/SSL/TCP%20Sender%20SSL.shtml#1ScriptAnchor_)
- [Network/SSL/TCP Socket SSL](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/SSL/TCP%20Socket%20SSL.shtml#1ScriptAnchor_)
- [Network/TCP Send and Receive/TCP Receiver](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/TCP%20Send%20and%20Receive/TCP%20Receiver.shtml#2ScriptAnchor_)
- [Network/TCP Send and Receive/TCP Sender](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/TCP%20Send%20and%20Receive/TCP%20Sender.shtml#1ScriptAnchor_)
- [Network/TCP Socket](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/TCP%20Socket.shtml#1ScriptAnchor_)
- [Network/Zebra ZPL Sample](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/Zebra%20ZPL%20Sample.shtml#1ScriptAnchor_)

This function is free to use.

Created 18th August 2014 , last changed 26th January 2016

  
[Socket.ClearNewConnectionHandler](SocketClearNewConnectionHandler.md) - [Socket.CloseAll](SocketCloseAll.md)

[HTML Version](SocketClose.shtml)