在这种情况下我该如何恢复?
服务器崩溃,因此连接异常关闭.对几乎所有内容的调用都会导致"对等连接重置"异常.我似乎已经通过在except块内的TIdTCPClient对象上调用Disconnect来修复它,但是它导致了一个带有相同消息的最终异常(我在第二个try-except块中捕获了它).
这与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;
Run Code Online (Sandbox Code Playgroud)
试试这个:
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;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13366 次 |
| 最近记录: |