作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在这种情况下我应该如何恢复?
服务器崩溃,连接异常关闭。对几乎所有内容的调用都会导致“对等方重置连接”异常。我似乎已经通过在 except block 内的 TIdTCPClient 对象上调用 Disconnect 来修复它,但它导致了一个带有相同消息的最终异常(我在第二个 try-except block 中捕获了它)。
这是 Indy10 和 Delphi XE2。
try
if not EcomSocket.Connected then EcomSocket.Connect();
except
on e: Exception do begin
try
EcomSocket.Disconnect();
except
MessageDlg('Connectivity to the server has been lost.', mtError, [mbOK], 0);
end;
end;
end;
最佳答案
试试这个:
try
if not EcomSocket.Connected then EcomSocket.Connect();
except
try
EcomSocket.Disconnect(False);
except
end;
if EcomSocket.IOHandler <> nil then EcomSocket.IOHandler.InputBuffer.Clear;
MessageDlg('Connectivity to the server has been lost.', mtError, [mbOK], 0);
end;
关于delphi - 从 "Connection Reset By Peer"Indy TCP 客户端恢复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10516579/
我是一名优秀的程序员,十分优秀!