santhi has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am using different port to get the ftp connection to the server because of the fire wall settings in that server.

I am able to connect to that server using this port number.
I can even change the directories also.

But I am unable to put the files to any directory, list the files present in any directory.
By giving the commands like put <filename> or ls
after 1-2 miuntes a message is being dispalyed as "Connection closed by remote host" and connection is being closed.

Could anyone of you please suggest me how i can proceed?

Thanks
  • Comment on FTP Connection using the different Port than the default

Replies are listed 'Best First'.
Re: FTP Connection using the different Port than the default
by Anonymous Monk on Nov 22, 2006 at 12:24 UTC
    That's the difference between active and passive FTP. The default mode of FTP is active, which means that for data transfer, a different channel is opened (and is initiated from the server). With passive mode, data and commands share the same channel.

    Use the Passive option in your Net::FTP constructor (assuming you are using Net::FTP).

      I don't think that's true. Passive mode will also open a different channel as far as I know.

      The only difference between active and passive mode is the direction of the data channel. In passive mode, the client will connect to the server, while in active mode the server will connect to the client.

      That being said, passive mode may get things working since the firewall may allow connections in the other direction.

      Update: I had active and passive reversed. Fixed now. See also http://slacksite.com/other/ftp.html