本文介绍了从“对等连接重置”中恢复; Indy TCP客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这种情况下我应该如何恢复?
How should I be recovering in this situation?
服务器崩溃,因此连接已异常关闭。对几乎所有内容的调用都会导致对等连接重置异常。我似乎已经通过在except块内的TIdTCPClient对象上调用Disconnect修复了该问题,但是它导致了一个最终异常,该消息带有相同的消息(这是我在第二个try-except块中捕获的)。
The server crashes, thus the connection has been abnormally closed. Calls to almost everything result in "Connection Reset By Peer" exceptions. I seem to have fixed it by calling Disconnect on the TIdTCPClient object inside the except block, but it results in one final exception with the same message (which I have caught in the second try-except block).
这与Indy10和Delphi XE2一起使用。
This is with Indy10 and 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;
这篇关于从“对等连接重置”中恢复; Indy TCP客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!