ClientTCP: TIdTCPClient;为什么我的ClientTCP想停停不下来
请问一下这个问题一般都是什么情况造成的......我该从哪几个方面入手找错误源.....错误提示如附件图片所示:
工程client.exe检测到错误类eidnotconnected,错误类型 not connected 进程中止..
我看了启动时创建的东东,应该都消到了..一运行到ClientTCP.Disconnect;就卡住了..也就是clienttcp连接不能断开
观察进程发现,程序运行好好的时候,进程名叫client,tcp,established(状态),卡住后就状态变成time wait ,名字unknown
代码好长.
procedure TRealMessengerX.ClientLogout();
var
iLoop: Integer;
EmployeePointer: PEmployee;
ChatingForm: TChatingForm;
AudioHandShake: TAudioHandShake;
VideoHandShake: TVideoHandShake;
TransmitFile: TTransmitFile;
MySocket: TMySocket;
begin
if CheckPOP3ThreadHandle <> 0 then TerminateThread(CheckPOP3ThreadHandle, 4);
CheckPOP3ThreadHandle := 0;
LblMailCount.Caption := '0 封电子邮件';
LblMailCount.Enabled := False;
TimerAutoConnect.Enabled := False;
TimerLoging.Enabled := False;
KeepP2PSessionTimer.Enabled := False;
PBLogin.Visible := False;
LblLoging.Visible := False;
LblCancelLogin.Visible := False;
CoolTrayIcon.CycleIcons := False;
MsgAlertQueue.Clear;
TrevUserList.Hide;
STimer.Enabled := False;
MConnect.Enabled := True;
MConnect.Caption := '登录(&I)';
MConnectSet.Enabled := True;
MDisconnect.Enabled := False;
MMyState.Enabled := False;
MSendMsg.Enabled := False;
MSendFile.Enabled := False;
MSendVoice.Enabled := False;
MSendVideo.Enabled := False;
MShowHistory.Enabled := False;
NR1.Enabled := False;
NR2.Enabled := False;
NR3.Enabled := False;
NR4.Enabled := False;
NR5.Enabled := False;
HartTimer.Enabled := False;
for iLoop := ChatingFormList.Count - 1 downto 0 do
begin
ChatingForm := ChatingFormList.Items[iLoop];
ChatingFormList.Remove(ChatingForm);
try
if (ChatingForm is TChatingForm) then ChatingForm.Free;
except
end;
end;
with VideoHandShakes.LockList do
try
for iLoop := Count - 1 downto 0 do
begin
VideoHandShake := Items[iLoop];
VideoHandShake.Free;
VideoHandShakes.Remove(VideoHandShake);
end;
finally
VideoHandShakes.UnlockList;
end;
with AudioHandShakes.LockList do
try
for iLoop := Count - 1 downto 0 do
begin
AudioHandShake := Items[iLoop];
AudioHandShake.Free;
AudioHandShakes.Remove(AudioHandShake);
end;
finally
AudioHandShakes.UnlockList;
end;
with TransmitFiles.LockList do
try
for iLoop := Count - 1 downto 0 do
begin
TransmitFile := Items[iLoop];
TransmitFile.Free;
TransmitFiles.Remove(TransmitFile);
end;
finally
TransmitFiles.UnlockList;
end;
with Employees.LockList do
try
for iLoop := 0 to Count - 1 do
begin
EmployeePointer := Items[iLoop];
EmployeePointer.State := '断开';
EmployeePointer.HaveAudioDevice := False;
EmployeePointer.HaveVideoDevice := False;
UpdateListViewStates(TrevUserList, EmployeePointer.Node); {更新用户状态}
FreeMem(EmployeePointer, SizeOf(Employee));
end;
finally
Employees.UnlockList;
end;
Employees.Clear;
with Branchs.LockList do
try
for iLoop := 0 to Count - 1 do FreeMem(Items[iLoop], SizeOf(Branch));
finally
Branchs.UnlockList;
end;
Branchs.Clear;
UpdateMyState();
TrevUserList.Items.Clear;
Me := nil;
if not DontAutoConnect then
begin
TimerAutoConnect.Interval := AutoConnectInterval * 1000;
TimerAutoConnect.Enabled := True;
end;
with MySockets.LockList do
try
for iLoop := Count - 1 downto 0 do
begin
try
MySocket := Items[iLoop];
MySocket.Free;
MySocket := nil;
except
end;
end;
finally
MySockets.UnlockList;
end;
if ClientTCP.Connected then
begin
ClientTCP.OnDisconnected := nil;
ClientTCP.Disconnect;
end;
end;
注销,退出都会运行这里