Sample code for 30+ languages & platforms
Visual Basic 6.0

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 Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

Dim socket As New ChilkatSocket

'  Connect to the server using TLS.
Dim bTls As Long
bTls = 1
Dim maxWaitMs As Long
maxWaitMs = 5000
success = socket.Connect("example.com",5000,bTls,maxWaitMs)
If (success = 0) Then
    Debug.Print socket.LastErrorText
    Exit Sub
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 Long
bAvailable = socket.PollDataAvailable()
If (bAvailable <> 1) Then
    Debug.Print "No data is immediately available."
Else
    Debug.Print "Data is available to read."
End If