Occurs when data is available to be read from the socket.
The OnRead event occurs when data is available to be read from the socket. This event is level-triggered, which means that once this event fires, it will not occur again until some data has been read from the socket. This design prevents an application from being flooded with event notifications. It is recommended that your application read all of the available data from the socket and store it in a local buffer for processing. See the example below.
This event is only generated if the socket is in non-blocking mode.
[Visual Basic]
Private Sub Socket_OnRead(ByVal sender As Object, ByVal e As System.EventArgs) Handles Socket.OnRead
Dim strBuffer As String
Dim nRead As Integer
Do
' Read up to m_nBufferSize bytes of data from the socket
nRead = Socket.Read(strBuffer, m_nBufferSize)
If nRead > 0 Then
' Append the data to an internal buffer for processing
m_dataBuffer = m_dataBuffer + strBuffer
End If
Loop Until nRead < 1
ProcessData()
End Sub