C
cocainy
Unregistered / Unconfirmed
GUEST, unregistred user!
我碰到这样一个问题,就是当VC写的Server程序关闭后,怎么IdTcpClient的连接还保持着呢<我用F7跟踪的时候,总是连接着 >,另外我在运行->cmd->netstat -a -n 查看连接状态显示已经断开!!!我贴上源代码,网富翁之点。
//检测是否连接的线程
TThreadCheckConn = class(TThread)
private
{}
protected
procedure Execute; override;
procedure ShowConnState;
end;
procedure TThreadCheckConn.Execute;
begin
Self.FreeOnTerminate:=True;
repeat
//Synchronize(Self.ShowConnState);
Self.ShowConnState
until Self.Terminated;
end;
procedure TThreadCheckConn.ShowConnState;
var
i : integer;
begin
//检查IdTcpClient的连接状态,如果没有连接,则连接
try
{****** 下面的这个判断怎么在Server程序关闭后却总是为真呢 *******}
if not (FrmMain.IdTCPClient.Connected) then
FrmMain.IdTCPClient.Connect(500);
except
FrmMain.StatusBar.Panels[2].Text:='与采集端连接失败'
end;
end;
//检测是否连接的线程
TThreadCheckConn = class(TThread)
private
{}
protected
procedure Execute; override;
procedure ShowConnState;
end;
procedure TThreadCheckConn.Execute;
begin
Self.FreeOnTerminate:=True;
repeat
//Synchronize(Self.ShowConnState);
Self.ShowConnState
until Self.Terminated;
end;
procedure TThreadCheckConn.ShowConnState;
var
i : integer;
begin
//检查IdTcpClient的连接状态,如果没有连接,则连接
try
{****** 下面的这个判断怎么在Server程序关闭后却总是为真呢 *******}
if not (FrmMain.IdTCPClient.Connected) then
FrmMain.IdTCPClient.Connect(500);
except
FrmMain.StatusBar.Panels[2].Text:='与采集端连接失败'
end;
end;