RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TWinSocketStream.Write Method

Writes Count bytes from Buffer to the socket connection.

Pascal
function Write(const Buffer; Count: Longint): Longint; override;
C++
virtual __fastcall Longint Write(const  Buffer, Longint Count);

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. 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!