Sample code for 30+ languages & platforms
Xojo Plugin

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 Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

Dim socket As New Chilkat.Socket

//  Connect to the server using TLS.
Dim bTls As Boolean
bTls = True
Dim maxWaitMs As Int32
maxWaitMs = 5000
success = socket.Connect("example.com",5000,bTls,maxWaitMs)
If (success = False) Then
    System.DebugLog(socket.LastErrorText)
    Return
End If

//  Perform a nonblocking check for readable data.  Returns 1 when data or another read-ready
//  condition is present, and 0 when nothing is immediately available.
Dim bAvailable As Boolean
bAvailable = socket.PollDataAvailable()
If (bAvailable <> True) Then
    System.DebugLog("No data is immediately available.")
Else
    System.DebugLog("Data is available to read.")
End If