The page you cite doesn't reproduce the messages very well. Here's what Remy really wrote:
SendCmd() is designed for textual commands/parameters only. You would have
to send the binary data after SendCmd() exited, and the server would have to
read the binary data after sending a response back to the client. For
example:
--- client ---
begin
IdTCPClient1.SendCmd('DoIt', 200);
// send binary data, such as with Write(TStream) or Write(TIdBytes)...
end;
The Write
methods he was talking about are members of the TIdIOHandler
class. Your TIdTCPConnection
object has an instance of that class in its IOHandler
property, and indeed that's what the SendCmd
function uses to send its string.
The notation Write(TIdBytes)
means to use the Write
method that accepts a TIdBytes
parameter for its input.
If the binary data is already in a stream or a dynamic array of bytes, then you can pass one of those directly to the Write
method. There's also the WriteFile
method that will send an entire external file if you provide the file's name. If you use the stream version, then you have the option of including the stream's length automatically.
If you don't have your data in one of those structures already, then you can either write the data piecemeal with the Write
methods that accept variously sized integer types, or you can copy your data into a TMemoryStream
and then pass that to Write
.