Socket.ReadHex
--------------

Reads bytes from socket and returns them hex encoded.

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

MBS( "Socket.ReadHex"; SocketID; Length ) 

**MBS**( **"Socket.ReadHex";** /\* Reads bytes from socket and returns them hex encoded. \*/  
**$SocketID**; /\* The socket ID received by [Socket.Connect](SocketConnect.md) function.e.g. $sock \*/   
**$Length**) /\* Maximum number of bytes to read.e.g. 10 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| SocketID | The socket ID received by [Socket.Connect](SocketConnect.md) function. | $sock |
| Length | Maximum number of bytes to read. | 10 |

### Result

Returns text encoded as hex or error message.

### Description

Reads bytes from socket and returns them hex encoded.  
The text returned may be shorter than length bytes.  
### Examples

Read up to 8 bytes and return them as:

 $value = MBS ( "Socket.ReadHex"; $port ; 8 )  
### See also

- [Socket.Connect](SocketConnect.md)
- [Socket.PeekHex](SocketPeekHex.md)
- [Socket.Read](SocketRead.md)
- [Socket.ReadAll](SocketReadAll.md)
- [Socket.ReadAllHex](SocketReadAllHex.md)
- [Socket.ReadLine](SocketReadLine.md)
- [Socket.ReadLineHex](SocketReadLineHex.md)
- [Socket.ReadMLLP](SocketReadMLLP.md)
- [Socket.WriteHex](SocketWriteHex.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)

This function is free to use.

Created 18th August 2014 , last changed 18th August 2014

  
[Socket.ReadAllHex](SocketReadAllHex.md) - [Socket.ReadLine](SocketReadLine.md)

[HTML Version](SocketReadHex.shtml)