Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Mar : Re: FTP in Thread
| Subject: | Re: FTP in Thread |
| Posted by: | "sham" (shamre..@inspirationmatters.com) |
| Date: | Mon, 10 Apr 2006 12:53:06 |
Hi Guillem,
I removed all the threading code and created two applications, one the FTP
Server and the other the FTP Client. I could not get this to work due to the
time outs and then sometimes getting the stack dumps that I have shown in
previous threads.
I am testing locally and have not proxy settings. For authentication, I just
code the onauthenticate event and accepted the login.
So, what am I doing wrong in this simple demo without threads?
Sham.
"Guillem" <guillemvicens-nospam@clubgreenoasis.com> wrote in message
news:xn0ektbc76d5wc002@newsgroups.borland.com...
> sham wrote:
>
>> Further to may last email:
>>
>> 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;
>
> that's a very short timeout. Default value is 60000.
>
> What kind of authentication are you using on the server?
>
> OTOH I see you are not setting any proxy values. I guess you are not
> working with any, are you?
>
>>
>> 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;
>
> where do you create the worker thread?
>
>>
>> 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;
>>
>> That is pretty much it.
>>
>
> --
> Best regards :)
>
> Guillem Vicens Meier
> Dep. Informatica Green Service S.A.
> www.clubgreenoasis.com
> --
> In order to contact me remove the -nospam