Reputation: 15158
I'm uploading lots of files (about 2000) using Commons-net FTPClient.
I'm checking connection before each upload using isAvailable()
& isConnected()
methods and reconnect if connection closed.
after uploading some files (variable) storeFileStream
returns null
(that means "data connection cannot be opened" as javadoc) while isAvailable()
& isConnected()
both are true !!
What is the problem?
How can I check data connection availability?
Thanks
Upvotes: 1
Views: 3035
Reputation: 1145
You can also try calling getReplyCode()
.
Returns the integer value of the reply code of the last FTP reply. You will usually only use this method after you connect to the FTP server to check that the connection was successful since connect is of type void.
You can check what those codes mean from this Wikipedia link
Upvotes: 0
Reputation: 310850
How can I check data connection availability?
Try to use it. There is no 'dial tone' in TCP, so methods with names like isConnected()
can't do anything more than tell you (1) whether you have ever connected, and, if you're lucky, (2) whether you have subsequently closed the connection or encountered an I/O error on it. I'm not familiar with the API you mention but the isConnected()
methods of the JDK classes don't do anything beyond (1).
Upvotes: 3