SocketTools .NET Edition

FtpClient.OnRead Event

Occurs when data is available to be read from the socket.

[Visual Basic]
Public Event OnRead As EventHandler
[C#]
public event EventHandler OnRead;

Remarks

The OnRead event occurs when data is available to be read from the server. 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 server. 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 server and store it in a local buffer for processing. See the example below.

This event is only generated if the client is in non-blocking mode.

Example


[Visual Basic]
Private Sub FtpClient1_OnRead(ByVal sender As Object, ByVal e As System.EventArgs) Handles FtpClient1.OnRead
    Dim strBuffer As String
    Dim nRead As Integer
 
    Do
        ' Read up to m_nBufferSize bytes of data from the socket
        nRead = FtpClient1.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
    

See Also

FtpClient Class | SocketTools Namespace