OnRead Event  
 

The OnRead event is generated when a client has sent data to the server.

Syntax

Sub object_OnRead ( [Index As Integer,] ByVal Handle As Variant )

Remarks

The OnRead event is generated when the client sends data to the server. The Handle argument specifies the handle to the client socket which can be used with the Read or ReadLine methods to read the data that was sent.

The application should not call the Read method repeatedly inside the OnRead event handler. When this event fires, it guarantees that data can be read from the specified client without causing the program to enter a blocked state. However, calling this method multiple times inside the event handler may cause the application to block when there is no more data available to read and this can negatively impact the overall performance of the server.

The preferred approach is to call the Read method once inside the event handler, buffer and/or process the data received from the client and exit the event handler. If there is more data available to be read from the client, the OnRead event will fire again. If you must call the Read method multiple times within the event handler, first check the value of the IsReadable property to determine if there is data available to be read.

See Also

IsReadable Property, Peek Method, Read Method, Write Method, OnWrite Event