现有一函数代码
Function Get_For_Host_ByIdHttp(aHost , aUrl: string) : Boolean ;
var
IdHTTP1: TIdHTTP;
begin
try
Result := True;
IdHTTP1 := TIdHTTP.Create(nil); with IdHTTP1 do
begin
try
ReadTimeout := 15000;
Port := 80 ;
Host := aHost;
Connected ; DataString := Get(aUrl) ;
except
on E: Exception do
begin
Result := False;
end;
end;
end;
finally
IdHTTP1.DisconnectSocket ;
IdHTTP1.Free;
end;
end
有一线程不停调用该函数,时间长后会出现#10053错误。并且该函数无法继续执行,导致线程中断。但重新启动一下线程又恢复正常。请问各位高手有什么办法能够屏蔽该错误,能让该函数能够稳定的执行。即使出错也能够跳出去。 不胜感谢
Function Get_For_Host_ByIdHttp(aHost , aUrl: string) : Boolean ;
var
IdHTTP1: TIdHTTP;
begin
try
Result := True;
IdHTTP1 := TIdHTTP.Create(nil); with IdHTTP1 do
begin
try
ReadTimeout := 15000;
Port := 80 ;
Host := aHost;
Connected ; DataString := Get(aUrl) ;
except
on E: Exception do
begin
Result := False;
end;
end;
end;
finally
IdHTTP1.DisconnectSocket ;
IdHTTP1.Free;
end;
end
有一线程不停调用该函数,时间长后会出现#10053错误。并且该函数无法继续执行,导致线程中断。但重新启动一下线程又恢复正常。请问各位高手有什么办法能够屏蔽该错误,能让该函数能够稳定的执行。即使出错也能够跳出去。 不胜感谢
except
on E: Exception do
begin
Result := False;
end;
end;
这种方法也不能屏蔽该错误。
Software caused connection abort.
tryexcept
on e;Exception do
begin
if e.Message='Socket Error # 10053'++#13+#10+Software caused connection abort.'
begin
eixt;
end;
end;
end; //用户名称不对,为空的情况。
if st='''USER '': Invalid number of parameters'+#13+#10 then
begin
ETips:='登录文件服务器的用户名称不对,请认真输入';
end;