Socket.LastError
----------------

Queries the last error code for the given socket.

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

MBS( "Socket.LastError"; SocketID ) 

**MBS**( **"Socket.LastError";** /\* Queries the last error code for the given 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 error code.

### Description

Queries the last error code for the given socket.  
This is normally a platform dependent error code.  
On macOS error code is 9 in use the socket is closed, on Windows 10009.  
### See also

- [Socket.Connect](SocketConnect.md)
- [Socket.Write](SocketWrite.md)
- [Socket.WriteByte](SocketWriteByte.md)
- [Socket.WriteHex](SocketWriteHex.md)
- [Socket.WriteMLLP](SocketWriteMLLP.md)

### Blog Entries

- [Socket changes for MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2020-08-31/Socket_changes_for_MBS_FileMak/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.3pr1](https://www.mbsplugins.de/archive/2014-07-02/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 18th August 2014 , last changed 31st August 2020

  
[Socket.IsListening](SocketIsListening.md) - [Socket.LastMessageIP](SocketLastMessageIP.md)

[HTML Version](SocketLastError.shtml)