AutoIt
AutoIt
Poll a Socket for Available Data
See more Socket/SSL/TLS Examples
Demonstrates Socket.PollDataAvailable, which performs a nonblocking check for readable activity and returns whether data or another read-ready condition is present.
Background. This lets an application check for incoming data without blocking, for example in an event loop that services multiple tasks.
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
; Perform a nonblocking check for readable data. Returns True when data or another read-ready
; condition is present, and False when nothing is immediately available.
Local $bAvailable = $oSocket.PollDataAvailable()
If ($bAvailable <> True) Then
ConsoleWrite("No data is immediately available." & @CRLF)
Else
ConsoleWrite("Data is available to read." & @CRLF)
EndIf