Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Oct : Re: Using TIdTCPClient and TIdTCPServer

www.cryer.info
Managed Newsgroup Archive

Re: Using TIdTCPClient and TIdTCPServer

Subject:Re: Using TIdTCPClient and TIdTCPServer
Posted by:"Mikael Lenfors" (mika..@lenfors.se)
Date:Tue, 3 Oct 2006 07:54:49

Ok thanks!

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> skrev i meddelandet
news:45217836$1@newsgroups.borland.com...
>
> "Mikael Lenfors" <mikael@lenfors.se> wrote in message
> news:452113cf$1@newsgroups.borland.com...
>
>> I thougth the Indy TCPClient and Indy TCPServer would do fine.
>
> They will work fine for that.
>
>> I tried the following:
>
> Your code is using the components wrong.  Use this code instead:
>
>    --- Application A ---
>
>    IdTCPClient.Connect;
>    try
>        IdTCPClient.SendCmd('Test', 250);
>        Tx := IdTCPClient.LastCmdResult.Text;
>    finally
>        IdTCPClient.Disconnect;
>    end;
>
>
>    --- Applicaton B ---
>
>    procedure TForm5.IdTCPServerExecute(AContext: TIdContext);
>    var
>        Txt: String;
>    begin
>        Txt := Trim(AContext.Connection.IOHandler.ReadLn);
>        AContext.Connection.IOHandler.Write('250 responsedata');
>    end;
>
>
> With that said, if you are going to use SendCmd() on the client side, then
> you should consider using TIdCmdTCPServer instead of TIdTCPServer on the
> server side.  That way you can process individual commands using less code
> and more event handlers that you can assign at design-time, ie:
>
>    --- Applicaton B ---
>
>    // add an entry to the TIdCmdTCPServer.CommandHandlers collection,
>    // configure as desired, and then assign this as its OnCommand event
> handler ...
>
>    procedure TForm5.CommandTest(ASender: TIdCommand);
>    begin
>        ASender.Reply.SetReply(250, 'responsedata');
>    end;
>
>
> Gambit

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive