procedure TDownThread.Execute;
var IdFtp1:TIDFTP;
begin
  IdFtp1:=TIDFTP.Create(nil);
  IdFtp1.Host:=FHost;
  IdFtp1.Username:=FUserName;
  IdFtp1.Password:=FPassword;
  IdFtp1.Port:=FPort;
  try
    IdFtp1.Connect(True,5000);
    Synchronize(ConnectionSeceess);
    FtpFlag:=True;
  except
    Synchronize(ConnectionFail);
    FtpFlag:=False;
  end;
  if FtpFlag then
  begin
    try
      IdFtp1.Get(FRemoteStr,FLocalStr,True);
      ThreadCount:=ThreadCount-1;
      Synchronize(DownSeceess);
    except
      Synchronize(DownFail);
    end;
    IdFtp1.Abort;
  end;
  IdFtp1.Free;
end;用FTP多线程下载大约下载了150个文件后就提示Connection time out
排除文件的问题,试过其它目录的文件还是在相同的位置提示Connection time out
哪位达人帮忙看看
 

解决方案 »

  1.   

    IDFTP的确如此,一段时间内不操作就会自动断掉连接,你可以这么写
    procedure TSysFrm.Timer1Timer(Sender: TObject);
    begin
      if not idftp1.Connected then
        idftp1.Noop;
    end;timer的Interval值为 3000
      

  2.   

    我是一起下载的1000+文件,每次都是下载了150个后就出现Connection time out 
    我的线程中每次建立的时候都会去连接服务器,应该不可能出现一段时间内不操作就会自动断掉连接
      

  3.   

    但是服务器会定时关闭空连接,客户端要发送保持命令才能维持这个过程,另外indy10有一个timeout setting,设置一下应该能解决这个问题
      

  4.   


    procedure TDownThread.Execute;
    var IdFtp1:TIDFTP;
    begin
      IdFtp1:=TIDFTP.Create(nil);
      IdFtp1.Host:=FHost;
      IdFtp1.Username:=FUserName;
      IdFtp1.Password:=FPassword;
      IdFtp1.Port:=FPort;
      try
        IdFtp1.Connect(True,5000);//我调试看是在这个地方出错了,但是
                                       //为什么前面的150个都可以连接,而后面却Connection time out
        Synchronize(ConnectionSeceess);
        FtpFlag:=True;
      except
        Synchronize(ConnectionFail);
        FtpFlag:=False;
      end;
      if FtpFlag then
      begin
        try
          IdFtp1.Get(FRemoteStr,FLocalStr,True);
          ThreadCount:=ThreadCount-1;
          Synchronize(DownSeceess);
        except
          Synchronize(DownFail);
        end;
        IdFtp1.Abort;
      end;
      IdFtp1.Free;
    end;
      

  5.   

    为什么要一直把FTPd连接着呢,下个文件连一下,下个文件连一下,应该不会发生超时这种情况吧。
      

  6.   

    现在就是这样做的,下个文件连一下,下完后就关闭了
    但还是下了一定数量的文件后就出现connection time out的错
    我把超时时间设置的很长就会出现假死现象