FTP access violation in simple demo.

Giganews Newsgroups
Subject: FTP access violation in simple demo.
Posted by:  sham (shamre…@inspirationmatters.com)
Date: Sat, 8 Apr 2006

Hi,

I need of some help. I posted to the wrong newsgroup before.

I have setup a simple FTP client and FTP server. I am using indy 9.0.18.

Client :
procedure TForm1.Button1Click(Sender: TObject);
var
  FFTPClient: TIdFTP;
  i : integer;
  FileList : TStringList;
  currentDirectory : String;
  FileStream : TFileStream;
  filename : string;
  sizeOfFile : integer;
begin
  Button1.Enabled := False;

  currentDirectory :=
IncludeTrailingPathDelimiter(ExtractFileDir(Application.ExeName));
  for i := 1 to 100 do
    begin
      FileList := TStringList.Create;
      try
        FileList.Add('TestDemo' + intToStr(i));
        fileName := currentDirectory + 'TestDemo' + intToStr(i) + '.dat';
        FileList.SaveToFile(fileName);
      finally
        FileList.Free;
      end;
    end;

  FFTPClient:= TIdFTP.create(nil);
  try
    FFTPClient.Host := '127.0.0.1';
    FFTPClient.Port := 21;
    FFTPClient.Username := 'abc';
    FFTPClient.Password := '';
    FFTPClient.TransferType := ftBinary;
    FFTPClient.ReadTimeout := 5000;

    FFTPClient.Connect();
    try
      for i := 1 to 100 do
        begin
          fileName := 'TestDemo' + intToStr(i) + '.dat';
          FileStream := TFileStream.Create(fileName, fmOpenRead);
          try
            sizeOfFile := FileStream.Size;

            FFTPClient.Put(FileStream, fileName + '-FS=' +
intToStr(sizeOfFile));
          finally
            FileStream.Free;
          end;
        end;

  finally
    FFTPClient.Disconnect;
  end;
  finally
    FFTPClient.Free;
  end;

  Button1.Enabled := True;
end;

Server :

procedure TForm1.IdFTPServer1StoreFile(ASender: TIdFTPServerThread;
  const AFileName: String; AAppend: Boolean; var VStream: TStream);
var
  tempFileName : string;
begin
  tempFileName := StringReplace(AFileName, '/', '\', [rfReplaceAll]);
  VStream := TFileStream.Create('D:\data' + tempFileName, fmCreate);
end;

procedure TForm1.IdFTPServer1UserLogin(ASender: TIdFTPServerThread;
  const AUsername, APassword: String; var AAuthenticated: Boolean);
begin
AAuthenticated := True;
end;

Access violation raised:

On the Server and two of them have
> the stacks:
> Thread 1 (on server)
> TIdStackWindows.WSSelect(???,???,nil,???)
> CheckIsReadable(4561208)
> TIdSocketHandle.Readable(-2)
> TIdIOHandlerSocket.Readable(???)
> TIdTCPConnection.ReadFromStack(True,-2,True)
> TIdTCPConnection.ReadLn(#$A,-1,16384)
> TIdTCPServer.DoExecute($E24A38)
> TIdPeerThread.Run
> TIdThread.Execute
>
> Thread 2 (on server)
> TIdStackWindows.WSSelect(???,???,nil,???)
> TIdSocketHandle.Select(???,4561208)
> TIdServerIOHandlerSocket.Accept(1796,$E24718)
> TIdListenerThread.Run
> TIdThread.Execute
>
> On the client the stack is:
> (on client when time out occurs)
> TIdTCPConnection.ReadFromStack(True,5000,True)
> TIdTCPConnection.ReadLn(#$A,-1,16384)
> TIdTCPConnection.ReadLnWait(2147483647)
> TIdTCPConnection.GetInternalResponse
> TIdTCPConnection.GetResponse((...))
> TIdTCPConnection.SendCmd(???,???)
> TIdFTP.SendPort($45A31C)
> TIdFTP.InternalPut('STOR TestDemo5.dat-FS=11',$CF37D0,True)
> TIdFTP.Put($CF37D0,'TestDemo5.dat-FS=11',False)
> TForm1.Button1Click(???)
> FTPSenderTest

Any help would be appreciated.

Sham.

Replies