Delphi版本: XE2,Indy版本: 10.5.8.0。我有三个程序,所有的工作都很好,直到失去网络连接。当它将发生之后,我会尝试发送消息,然后我不能重新连接,当互联网将回来。无法关闭程序(关闭程序后不可见,但将使用100 cpu使用率)。在没有"try,exception“的情况下,IdIRC1.Say和on Close上有一个Socket Error #1053。谢谢你的帮助。
///Connection:
procedure TForm1.Button5Click(Sender : TObject);
begin
try
IdIRC1.Nickname := 'zzz';
IdIRC1.Password := 'kkk';
if IdIRC1.Connected then
IdIRC1.Disconnect;
IdIRC1.Connect;
IdIRC1.Join('#' + edit3.Text);
except
ShowMessage('ggg');
end;
end;
///Send message:
procedure TForm1.Button3Click(Sender : TObject);
begin
try
IdIRC1.Say('#' + edit3.Text, edit2.Text);
if (edit2.Text <> '') and (IdIRC1.Connected) then
begin
memo6.Lines.Add(edit2.Text);
Edit2.Clear;
end
else
ShowMessage('xxx');
except
ShowMessage('yyy');
end;
end;
///On close:
try
IdIRC1.Disconnect;
except
end;发布于 2013-06-29 04:48:51
当您在访问连接时遇到错误时,例如由于连接丢失,您需要调用Disconnect() ,如果IOHandler.InputBuffer中仍有未读数据,则需要清除它。根据设计,Disconnect()不会清除InputBuffer。如果InputBuffer不为空,则即使物理套接字断开连接,Connected()也将返回True。
https://stackoverflow.com/questions/17362597
复制相似问题