DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoSocket
Boolean iBTls
Integer iMaxWaitMs
Boolean iBAvailable
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatSocket)) To hoSocket
If (Not(IsComObjectCreated(hoSocket))) Begin
Send CreateComObject of hoSocket
End
// Connect to the server using TLS.
Move True To iBTls
Move 5000 To iMaxWaitMs
Get ComConnect Of hoSocket "example.com" 5000 iBTls iMaxWaitMs To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoSocket To sTemp1
Showln sTemp1
Procedure_Return
End
// 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.
Get ComPollDataAvailable Of hoSocket To iBAvailable
If (iBAvailable <> True) Begin
Showln "No data is immediately available."
End
Else Begin
Showln "Data is available to read."
End
End_Procedure