当我在IDTCPSERVER中将连接线程DISCONNECT以后,IDTCPCLIENT的CONNECT属性居然还是已连接?
如何完全断开IDTCPSERVER和IDTCPCLIENT之间的连接并销毁IDTCPSERVER的线程?
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, IdTCPConnection, IdTCPClient,
  IdBaseComponent, IdComponent, IdTCPServer;type
  TForm1 = class(TForm)
    s: TIdTCPServer;
    c: TIdTCPClient;
    ListView: TListView;
    CONNECT: TButton;
    DISCONNECT: TButton;
    procedure CONNECTClick(Sender: TObject);
    procedure sConnect(AThread: TIdPeerThread);
    procedure sExecute(AThread: TIdPeerThread);
    procedure sDisconnect(AThread: TIdPeerThread);
    procedure DISCONNECTClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.CONNECTClick(Sender: TObject);
begin
c.Connect(5000);
end;procedure TForm1.sConnect(AThread: TIdPeerThread);
VAR
  iTEM:tLISTiTEM;
begin
  ITEM:=LISTVIEW.Items.Add;
  ITEM.Data:=ATHREAD;end;procedure TForm1.sExecute(AThread: TIdPeerThread);
begin
REPEAT
  ATHREAD.Connection.CheckForGracefulDisconnect;
  ATHREAD.Suspend;
UNTIL ATHREAD.Terminated or (NOT ATHREAD.Connection.Connected);
end;
//  4120
procedure TForm1.sDisconnect(AThread: TIdPeerThread);
begin
  listView.FindData(0,Athread,true,true).Delete;end;procedure TForm1.DISCONNECTClick(Sender: TObject);
begin
  TIdPeerThread(ListView.Items[0]).connection.diSCONNECT;
  TIdPeerThread(ListView.Items[0]).RESUME;
end;end.

解决方案 »

  1.   

    是存在BUG,我也是最近在项目中才发现的。前阵子似乎推出了新版本,可以下载试试,没准改进了。
    ------------------------------------
    《CSDN论坛新助手 CSDN's forum Explorer》,支持最新改版论坛,回复、浏览“方便”,“快捷”!
    下载地址:http://www.seeyou.com.cn/CoolSlob/CSDNExplorer.exe
      

  2.   

    顺带说一声,如果新版本改好了,记得告诉我一声:)
    ------------------------------------
    《CSDN论坛新助手 CSDN's forum Explorer》,支持最新改版论坛,回复、浏览“方便”,“快捷”!
    下载地址:http://www.seeyou.com.cn/CoolSlob/CSDNExplorer.exe