我需要一个简单的例子:
 IdTCPClient ==> 传消息到==> IdTCPServer
 IdTCPServer ==> 传消息到==> IdTCPClient

解决方案 »

  1.   

    //简单些一个,具体实现的时候就不能这么简单了
    procedure TForm1.BitBtn1Click(Sender: TObject);
    begin
    self.IdTCPServer1.DefaultPort:=88888;
    self.IdTCPServer1.Active:=true;self.IdTCPClient1.Host:='127.0.0.1';
    self.IdTCPClient1.Port:=88888;
    try
      self.IdTCPClient1.Connect( 5000 );
      self.IdTCPClient1.Write( 'aaaaa' );
      showmessage( self.IdTCPClient1.ReadLn() );
      self.IdTCPClient1.Disconnect;
    except
    end;end;procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
    begin
      with AThread.Connection do
      begin
        if ReadLn = 'aaaaa' then
        begin
          Write( 'hello world' );
        end;
      end;
    end;
      

  2.   

    http://www.2ccc.com/article.asp?articleid=3894
      

  3.   

    http://www.2ccc.com/article.asp?articleid=3868
      

  4.   

    \Program Files\Borland\Delphi\Demos\Indy\BasicClientServer\
    \Program Files\Borland\Delphi6\Demos\Internet\Chat\
      

  5.   

    //简单些一个,具体实现的时候就不能这么简单了
    procedure TForm1.BitBtn1Click(Sender: TObject);
    begin
    self.IdTCPServer1.DefaultPort:=88888;
    self.IdTCPServer1.Active:=true;self.IdTCPClient1.Host:='127.0.0.1';
    self.IdTCPClient1.Port:=88888;
    try
      self.IdTCPClient1.Connect( 5000 );
      self.IdTCPClient1.Write( 'aaaaa' );
      showmessage( self.IdTCPClient1.ReadLn() );
      self.IdTCPClient1.Disconnect;
    except
    end;end;procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
    begin
      with AThread.Connection do
      begin
        if ReadLn = 'aaaaa' then
        begin
          Write( 'hello world' );
        end;
      end;
    end;