System.Win.ScktComp.TWinSocketStream.Write
Delphi
function Write(const Buffer; Count: Longint): Longint; override;
C++
virtual int __fastcall Write(const void *Buffer, int Count)/* overload */;
inline int __fastcall Write(const System::DynamicArray<System::Byte> Buffer, int Offset, int Count){ return System::Classes::TStream::Write(Buffer, Offset, Count); }
inline int __fastcall Write(const System::DynamicArray<System::Byte> Buffer, int Count){ return System::Classes::TStream::Write(Buffer, Count); }
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.Win.ScktComp.pas System.Win.ScktComp.hpp |
System.Win.ScktComp | TWinSocketStream |
Description
Writes Count bytes from Buffer to the socket connection.
Use Write to write data from a Buffer to the socket connection. Write returns the number of bytes transferred.
Write may return 0 if the socket connection is extremely slow and the write operation has not completed after TimeOut milliseconds. This ensures that the Write method does not hang indefinitely when a problem occurs with the socket connection.
To guard against the Write method timing out because of a slow connection, set Count fairly low, and make several calls to Write, rather than fewer calls with a large value of Count.
Unlike the WriteBuffer method, Write does not raise an exception if Count bytes are not written. For example, if the connection is too slow to transfer all the data, Write will return 0, where WriteBuffer will raise an exception.