Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Dec : Re: Transfering binary data from TidTCPClient to TidCmdTCPServer - HowTo?
| Subject: | Re: Transfering binary data from TidTCPClient to TidCmdTCPServer - HowTo? |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Tue, 4 Dec 2007 15:23:13 |
"Chris Ueberall" <CUeberall@web.de> wrote in message
news:4755cf6f$1@newsgroups.borland.com...
> How can I send binary data from a TidTCPClient to a TidCmdTCPServer?
> Is it possible to send the data with the SendCmd method?
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;
--- server ---
procedure TForm1.DoItCommand(ACommand: TIdCommand)
begin
//...
if (ok to send data) then
begin
ACommand.Reply.SetReply(200, 'Ready to receive data');
ACommand.SendReply;
// read binary data, such as with ReadStream() or ReadBytes()...
end else
ACommand.Reply.SetReply(500, 'Error!');
end;
> I streamed the data as param
The only way to do that is to encode the data into a textual format, such as
hex or base64, that has no line breaks in it after being encoded.
> can't access the data the right way at the server, property 'RawLine'
> cuts it at the first new line.
That is what Indy's CommandHandler system is supposed to do. It is designed
for line-based textual protocols.
Gambit