Socket.PeekHex
--------------

Peeks 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.PeekHex"; SocketID; Length ) 

**MBS**( **"Socket.PeekHex";** /\* Peeks 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

Peeks from socket and returns them hex encoded.  
The text returned may be shorter than length bytes.  
  
If you like to look into the whole buffer, please use [Socket.PeekAllHex](SocketPeekAllHex.md) function.  
### Examples

Read up to 8 bytes and return them as:

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

- [Socket.Connect](SocketConnect.md)
- [Socket.Peek](SocketPeek.md)
- [Socket.PeekAll](SocketPeekAll.md)
- [Socket.PeekAllHex](SocketPeekAllHex.md)
- [Socket.Read](SocketRead.md)
- [Socket.ReadHex](SocketReadHex.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 15th February 2019

  
[Socket.PeekAllHex](SocketPeekAllHex.md) - [Socket.Read](SocketRead.md)

[HTML Version](SocketPeekHex.shtml)