Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Mar : Re: INDY TIdTCPClient and TIdTCPServer Usage
| Subject: | Re: INDY TIdTCPClient and TIdTCPServer Usage |
| Posted by: | "Huang Xiaobin" (hxbtoug..@yahoo.com.cn) |
| Date: | Mon, 20 Mar 2006 21:59:49 |
Why not use TIdCmdTCPServer and TIdCmdTCPClient
"Dennis" <marianndkc@home3.gvdnet.dk> 写入消息新闻:441eb092$1@newsgroups.borland.com...
> Hi
>
> I am having some beginners problems using the TIdTCPClient and
> TIdTCPServer
> components
>
> I have made to basic Win32 applications - one for the client part and one
> as
> server.
>
> I am able to connect and send one string with the SendCMD method. The
> problem is that the method fails returning because it does not accept the
> answer from the server.
>
> I am using this code in the client
>
> IdTCPClient1.SendCmd('Hello', 'OK');
>
> and this in the server
>
> procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
> var
> lCmd: string;
>
> begin
> lCmd := Trim(AContext.Connection.IOHandler.ReadLn);
> //RichEdit1.Lines.Add('OnExecute triggered');
> RichEdit1.Lines.Add(lCmd);
> //AContext.Connection.IOHandler.WriteLn('Data Received');
> AContext.Connection.IOHandler.WriteLn('OK');
> //AContext.Connection.IOHandler.WriteLn('');
> end;
>
> The client raises an exception "Reply code is not valid: OK".
>
> I also tried this code
>
> IdTCPClient1.SendCmd('Hello', -1);
>
> but it fails too.
>
> What can be wrong?
>
> Best regards
> Dennis Kjaer Christensen