gpt4 book ai didi

delphi - 从 "Connection Reset By Peer"Indy TCP 客户端恢复

转载 作者:可可西里 更新时间:2023-11-01 02:30:30 32 4
gpt4 key购买 nike

在这种情况下我应该如何恢复?

服务器崩溃,连接异常关闭。对几乎所有内容的调用都会导致“对等方重置连接”异常。我似乎已经通过在 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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com