Handling Binary Data with Byte Array Properties
When working with binary data, string-based properties may alter byte values due to encoding or character conversion. To preserve the original data, IPWorks components provide byte-array equivalents of common properties for both sending and receiving data.
Sending Binary Data
For properties that send data (such as DataToSend or EOL), corresponding byte-array versions are available by appending B (for example, DataToSendB, EOLB). These allow you to work directly with raw bytes.
Dim A(0:5) as Byte 'remember to dim explicitly "0 to len-1"
For i=0 to 5
a(i) = chr(127+i)
next i
IPPort1.DataToSendB = A
Receiving Binary Data
When receiving data, string parameters (such as Text) may not accurately represent binary content. Instead, use the corresponding byte-array property (for example, DataInTextB) within the event to access the exact byte values.
Private Sub IPDaemon1_DataIn(ConnectionId As Integer, Text As String, EOL As Boolean)
Dim A() As Variant
A = IPDaemon1.DataInTextB ' Capture bytes immediately
Debug.Print Text
For I = LBound(A) To UBound(A)
Debug.Print A(I)
Next I
End Sub
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.