Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Mar : Re: FTP in Thread
| Subject: | Re: FTP in Thread |
| Posted by: | "Guillem" (guillemvicens-nospam@clubgreenoasis.com) |
| Date: | 10 Apr 2006 08:42:58 |
sham wrote:
> 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.
actually, I was speaking about the value of the AuthCMD property of the
FTP client. If you don't know what to assign then use tAuto
>
> So, what am I doing wrong in this simple demo without threads?
>
you need to have at least 2 event handlers implemented in the
idFTPServer: the OnRetrieveFile and the OnStoreFile. For example,
procedure TDataModule.IdFTPServerRetrieveFile(ASender:
TIdFTPServerContext;
const AFileName: string; var VStream: TStream);
begin
VStream := TFileStream.Create(MyFileName, fmOpenRead or
fmShareExclusive);
end;
procedure TDataModule.IdFTPServerStoreFile(ASender: TIdFTPServerContext;
const AFileName: string; AAppend: Boolean; var VStream: TStream);
begin
VStream := TFileStream.create(MyFileName, fmCreate or
fmShareExclusive ) ;
end;
I guess you did this but the server has also to be active to listen to
a client and the client's IP+port has to be in the bindings list of the
server. In local mode you need to have 127.0.0.1 or 0.0.0.0 (which
means listening to *all* IPs and is really not a good idea)
Also take in consideration that FTP is not very firewall-friendly due
to its need of 2 open connections. Make sure you haven't problems on
that side, and if you do, consider to use the passive mode (property in
client by default set to false) instead of active mode. You can find
more info in RFC959
--
Best regards :)
Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com