Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.apache.commons.net.ftp use different port

I want to connect to a FTP-Server via my Servlet and I know it works, but to use it on my virtual Server I need to change the Port the servlet connects to, because the FTP-Server doesn't use the standard port.

My problem is, that I don't know how I can tell the FTPClient not to use Port 21. For example it should use Port "55555".

The FTPClient only wants one parameter, the ip, to connect.

using org.apache.commons.net.ftp 
FTPClient ftp = new FTPClient();
ftp.connect("dyndns");

best SnowN

like image 818
Paixsn Avatar asked Feb 07 '14 11:02

Paixsn


People also ask

How do I import org Apache Commons Net FTPClient FTP?

Here's the official Apache download site for Commons Net. Once you've picked and extracted the appropriate version, set a dependency in your Eclipse project: Right-click the project and choose "Properties" Choose "Java Build Path" from the resulting popup.

What is the default FTP port number?

FTP communications use two port number values – one for commands (port 21 by default) and one for data transfer (this is where the PORT command comes into play). The PORT command is sent by an FTP client to establish a secondary connection (address and port) for data to travel over.

Does Apache FTPClient support SFTP?

Apache FTPClient doesn't support SFTP at the moment.

What is FTPClient in Java?

FTPClient encapsulates all the functionality necessary to store and retrieve files from an FTP server. This class takes care of all low level details of interacting with an FTP server and provides a convenient higher level interface.


1 Answers

you should use method connect(host,port)

like image 181
Leo Avatar answered Sep 18 '22 06:09

Leo