| Author |
Is FTPClient optimized to reuse open connections?
|
Talib Jockey
Greenhorn
Joined: Aug 06, 2003
Posts: 22
|
|
I am using org.apache.commons.net.ftp.FTPClient class to connect to a remote server for FTP. My doubt is that if I connect to the FTP Server using ftp.connect(), where ftp is a object of class FTPClient, I dont explicitly call ftp.disconnect() and again try connecting to the FTP Server through ftp.connect(), will it reuse the connection if it has not timedout? The catch is that I create a new FTPClient object each time I call connect(), somethin like this.. FTPClient ftp = null; ftp = new FTPClient(); ftp.connect(); ftp = new FTPClient(); ftp.connect(); Will it physically connect each time, or FTPClient(It uses Socket to connect) is optimized to reuse an exisitng open connection, inspite of the fact that I am creating a new object of FTPClient() each time?
|
SCJP 1.4 - 97%<br />SCWCD 1.4 - In Progress
|
 |
Jan Cumps
Bartender
Joined: Dec 20, 2006
Posts: 2343
|
|
If you use it's default configuration, FTPClient will use this class to create your connection: DefaultSocketFactory.java. It just uses java's standard java.net classes to open a connection. No caching or reuse involved. Regards, Jan (edit: I said cashing in stead of caching) [ March 03, 2007: Message edited by: Jan Cumps ]
|
OCUP UML fundamental
ITIL foundation
|
 |
Talib Jockey
Greenhorn
Joined: Aug 06, 2003
Posts: 22
|
|
Thanks Jan! So each time a new Socket object is created i.e. it will physically connect to the Server (I connect in the passive mode). Is that right?
|
 |
Jan Cumps
Bartender
Joined: Dec 20, 2006
Posts: 2343
|
|
Yes. Regards, Jan
|
 |
 |
|
|
subject: Is FTPClient optimized to reuse open connections?
|
|
|