(AutoIt) Send Bytes on a Socket Connection
Demonstrates how to send a mixture of binary (non-text) and text bytes on a socket connection.
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oSocket = ObjCreate("Chilkat.Socket")
; Connect to some host:port
Local $bSsl = False
Local $iMaxWaitMillisec = 20000
Local $iPort = 5555
Local $bSuccess = $oSocket.Connect("test.com",$iPort,$bSsl,$iMaxWaitMillisec)
If ($bSuccess <> True) Then
ConsoleWrite($oSocket.LastErrorText & @CRLF)
Exit
EndIf
; We wish to send a 0x00 byte followed by the us-ascii string "10800"
$oBd = ObjCreate("Chilkat.BinData")
$oBd.AppendByte(0)
$oBd.AppendString("10800","utf-8")
; Send the entire contents of bd.
$bSuccess = $oSocket.SendBd($oBd,0,0)
If ($bSuccess <> True) Then
ConsoleWrite($oSocket.LastErrorText & @CRLF)
Exit
EndIf
|