AutoIt
AutoIt
Receive Bytes up to a Delimiter into a BinData
See more Socket/SSL/TLS Examples
Demonstrates Socket.ReceiveUntilByteBd, which reads bytes until a delimiter byte is encountered and appends all bytes up to and including the delimiter to a BinData.
Background. The delimiter is a raw byte value from 0 through 255. This is useful for framing schemes that terminate each message with a known delimiter byte.
Chilkat AutoIt Downloads
Local $bSuccess = False
$oSocket = ObjCreate("Chilkat.Socket")
; Connect to the server using TLS.
Local $bTls = True
Local $iMaxWaitMs = 5000
$bSuccess = $oSocket.Connect("example.com",5000,$bTls,$iMaxWaitMs)
If ($bSuccess = False) Then
ConsoleWrite($oSocket.LastErrorText & @CRLF)
Exit
EndIf
; Read bytes until the delimiter byte is encountered, appending all bytes up to and including the
; delimiter to a BinData. The delimiter is a raw byte value from 0 through 255 (here the linefeed
; byte, decimal 10).
$oBd = ObjCreate("Chilkat.BinData")
$bSuccess = $oSocket.ReceiveUntilByteBd(10,$oBd)
If ($bSuccess = False) Then
ConsoleWrite($oSocket.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Received " & $oBd.NumBytes & " bytes (including the delimiter)." & @CRLF)