Socket.AvailableBytes
---------------------

Queries number of bytes in read buffer.

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

MBS( "Socket.AvailableBytes"; SocketID ) 

**MBS**( **"Socket.AvailableBytes";** /\* Queries number of bytes in read buffer. \*/  
**$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 number or error.

### Description

Queries number of bytes in read buffer.  
May not work for SSL sockets.  
  
The buffer size of the socket is managed by the OS and can be several megabytes big if needed.  
Changed in v10.4 to return error if socket is closed or disconnected instead of zero.  
### Examples

Query available byte count:

 MBS ( "Socket.AvailableBytes"; $sock )  
### See also

- [Socket.Connect](SocketConnect.md)

### Release notes

- **Version 10.4**
    - Improved [Socket](https://www.mbsplugins.eu/component_Socket.shtml) functions to better return errors. [Socket.AvailableBytes](https://www.mbsplugins.eu/SocketAvailableBytes.shtml), [Socket.Write](https://www.mbsplugins.eu/SocketWrite.shtml) or [Socket.Read](https://www.mbsplugins.eu/SocketRead.shtml) functions now return an error when socket is disconnected or otherwise broken.

### Blog Entries

- [MBS FileMaker Plugin, version 10.4pr7](https://www.mbsplugins.de/archive/2020-09-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [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.3pr11](https://www.mbsplugins.de/archive/2014-09-14/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 11st September 2014 , last changed 31st August 2020

  
[Socket.AddMembership](SocketAddMembership.md) - [Socket.Check](SocketCheck.md)

[HTML Version](SocketAvailableBytes.shtml)