Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Dec : Re: Help Please! - FTP Put() Exception : Invalid PORT Command - Indy 9
| Subject: | Re: Help Please! - FTP Put() Exception : Invalid PORT Command - Indy 9 |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Wed, 26 Dec 2007 12:05:59 |
"Johnnie Norsworthy" <jln206@verizon.net> wrote in message
news:4772b0a9@newsgroups.borland.com...
> I am trying to upload a file by FTP in Indy 9.
>
> FTP.Connect works fine
> FTP.ChangeDir() works fine
> FTP.Put(LocalFileName,RemoteFileName) give me an exception "Invalid PORT
> Command"
Without seeing a packet trace of the actual PORT command, it is hard to say
for sure, but the server probably does not support Active transfers. Try
setting the Passive property to true and try again.
> on tracing the code it seems the port command is a local port
> being assigned, not the remote port.
That is what it is supposed to be doing.
The FTP protocol uses separate socket connections for data transfers. For
"Active" transfers, the FTP client (TIdFTP in this case) opens a listening
socket that the FTP server has to actively connect to. The PORT command
tells the FTP server which port number the client is listening on.
For "Passive" transfers, on the other hand, the FTP server opens a listening
socket that the FTP client has to connect to. The reply to the PASV command
specifies the port number that the FTP server is listening on.
> I have disabled my software firewall for testing and my WS_FTP
> program has no problem connecting to the same site and uploading.
Chances are, WS_FTP is using Passive mode transfers. You should do that in
your own code anyway because Passive mode transfers are more
firewall-friendly than Active mode transfers.
> Also, can a remote port number be specified as par tof the .host property
No.
> do I need to use FTP.Port := to specify an alternate remote port?
Yes.
Gambit