RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomWinSocket.SendBuf Method

Writes Count bytes to the socket connection from the Buf parameter.

Pascal
function SendBuf(var Buf; Count: Integer): Integer;
C++
__fastcall int SendBuf( Buf, int Count);

Use SendBuf to write to the socket connection. Call this method from the OnSocketEvent event handler of a Windows socket object or in the OnWrite or OnClientWrite event handler of a socket component. Alternately, Use SendBuf to write when a connection is first formed when the socket does not expect notification that the socket on the other end of the connection is expecting to read. 

For non-blocking sockets, the data is sent to the WinSock DLL which has it's own internal buffers. If the WinSock can accept additional data, SendBuf returns immediately with the number of bytes queued. If the WinSock internal buffer space is not able to accept the buffer being sent, SendBuf returns -1 and no data is queued at all. In this case, wait a bit for the WinSock to have a chance to send out already-queued data; then try again. 

For blocking sockets, SendBuf returns the number of bytes actually written.  

If an error occurs while writing to the connection, SendBuf terminates the connection and raises an ESocketError exception. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!