I made a program that communicate with some electronic device using winsock udp protocol, i am trying to write a function that will tell me rather or not a device is online by looking at if anything is sent back from the device.

this is my function
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

Dim strData As String

Winsock1.GetData strData, vbString, bytesTotal

If Not Len(strData) = 0 Then
online = 1
End If

End Sub

i declared the variable "online" as a global variable, but somehow "online" is always 0...i think i am trying to do this the wrong way, can anyone give me a hand?