AutoIt
AutoIt
Receive Bytes into a BinData
See more Socket/SSL/TLS Examples
Demonstrates Socket.ReceiveBd, which receives one delivery of binary data and appends it to a BinData. It returns whatever is immediately available.
Background. The BinData receive methods accumulate raw bytes in a BinData object. A single receive returns only what is currently available, whereas the counted receive waits for an exact number of bytes.
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
; Receive one delivery of binary data and append it to a BinData. ReceiveBd returns whatever is
; immediately available; it does not loop to drain everything that may follow.
$oBd = ObjCreate("Chilkat.BinData")
$bSuccess = $oSocket.ReceiveBd($oBd)
If ($bSuccess = False) Then
ConsoleWrite($oSocket.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Received " & $oBd.NumBytes & " bytes." & @CRLF)