Question

I am using an instance of the Indy Component IdTCPClient to transfer data to a connected peer. The TIdTCPClient.IOHandler.Write() procedure is used for writing data onto the connection. However, there is no return value to indicate wheter or not the operation did succeed or fail. I know that the send() function of the Windows API returns the number of bytes that have been sent over the socket, but Indy capsulates that and does not show me any return value.

My question therefore is: does the TIdTCPClient.IOHandler.Write() procedure provide any kind of return value (maybe via a class member that gets filled? ) or does the procedure throw an exception if the operation failed? I need to make sure the Write() operation succeeded before continuing my application.

Thanks in advance!

Était-ce utile?

La solution

Indy uses exceptions for error reporting. If Write() exits without raising an exception then the socket successfully accepted the full data (that is not a guarantee that the peer actually received the data. The socket may have buffered it internally and will transmit it at a later time, for instance). Write() does not exit until the entire requested data has been "written" in full. It will call the socket API send() function as many times as it needs to accomplish that.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top