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: | Thu, 6 Apr 2006 14:32:05 |
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;
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;
That is pretty much it.
I am using 9.0.18.
There must be some sort of problem in my enviornment if I cannot get this
working.
As I mentioned before, when I use GuildFTP, all seems fine.
Sham.
"sham" <shamresh@inspirationmatters.com> wrote in message
news:44350837@newsgroups.borland.com...
> Hi,
>
> This is what I have done so far:
>
> Simple server application which has a TidFTPServer component and a
> OnStoreEvent that does a VStream := TFileStream(filename, fmCreate);
>
> That is all.
>
> Client App demo has no threads (taken them out) and loops 100 times and
> sends files. I still get a readTimeOut on the client:
>
> There are a number of threads running 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
>
> I have upgraded to 9.0.18 but cannot go to 10 since it breaks some other
> components.
>
> We have got to the point where we are about to scrap indy.
>
> Any help would be appreciated.
>
> Sham.
>
> Ps. I replaced the server with GuildFTP and there is no problem. So
> clearly the problem is with the ftp server code.
>
>
> "Martin James" <mjames_falcon@dial.pipex.com> wrote in message
> news:4433fc08$1@newsgroups.borland.com...
>>
>> "sham" <shamresh@inspirationmatters.com> wrote in message
>> news:4432690c$1@newsgroups.borland.com...
>>> Yes, I am creating a thread and doing the put inside it.
>>>
>>> I have moved up the sleep to 50.
>>>
>>> I am not using the latest dev snapshot. I am using version 9.0.14.
>>
>> 9.0.14?
>>
>> I'm fairly sure that I've used this version before in threads without nay
>> sleeps or other strangenesses. It worked fine. I'll try & make sure by
>> looking through my old projects.
>>
>> Rgds,
>> Martin