Read a data stream from the socket and store it in the specified byte array.
A byte array that the data will be stored in.
This method returns a boolean value. If the method succeeds, the return value is true. If the method fails, the return value is false. To get extended error information, check the value of the LastError property.
This method will force the current thread to block until the operation completes. If this method is called and the Blocking property is set to false, it will automatically switch the socket into a blocking mode, read the data stream and then restore the socket to non-blocking mode when it has finished. If another socket operation is attempted while ReadStream is blocked waiting for data from the remote host, an error will occur. It is recommended that this method only be used with blocking (synchronous) socket connections; if the application needs to establish multiple simultaneous connections, it should create worker threads to manage each connection.
It is possible for data to be returned in the buffer even if the method returns false. Applications should also check the value of the length parameter to determine if any data was copied into the buffer. For example, if a timeout occurs while the method is waiting for more data to arrive on the socket, it will return zero; however, data may have already been copied into the buffer prior to the error condition. It is the responsibility of the application to process that data, regardless of the method return value.
Because ReadStream can potentially cause the current thread to block for long periods of time as the data stream is being read, the class will periodically generate OnProgress events. An application can use this event to update the user interface as the data is being read. Note that an application should never perform a blocking operation inside the event handler.