System.Win.ScktComp.TWinSocketStream.Read
Delphi
function Read(var Buffer; Count: Longint): Longint; override;
C++
virtual int __fastcall Read(void *Buffer, int Count)/* overload */;
inline int __fastcall Read(System::DynamicArray<System::Byte> Buffer, int Offset, int Count){ return System::Classes::TStream::Read(Buffer, Offset, Count); }
inline int __fastcall Read(System::DynamicArray<System::Byte> &Buffer, int Count){ return System::Classes::TStream::Read(Buffer, Count); }
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.Win.ScktComp.pas System.Win.ScktComp.hpp |
System.Win.ScktComp | TWinSocketStream |
Description
Reads up to Count bytes from the socket connection into Buffer.
Use Read to read data from the socket connection when the number of bytes to be transferred is unknown. Buffer must have at least Count bytes allocated to hold the data that is read from the connection. Read returns the number of bytes actually transferred (which may be less than the number requested in Count.)
Read may return 0 if the socket connection is extremely slow and the read operation has not completed after TimeOut milliseconds. This ensures that the Read method does not hang indefinitely when a problem occurs with the socket connection.
To guard against the Read method timing out because of a slow connection, set Count fairly low, and make several calls to Read, rather than fewer calls with a large value of Count.
To ensure that the socket connection is ready to send data before calling Read, use the WaitForData method.
Unlike the ReadBuffer method, Read does not raise an exception if Count bytes are not read from the socket connection.