When do开发者_如何学Ces the setDataTimeout on FTPClient (commons.net) called? Does it called when the socket connection is hung or does it called when the time out value is reached?
For eg. if I set the setDataTimeout to 30 seconds I don't want the connection to be disconnect after 30 seconds in the middle of a big download.
You should call the setDataTimeout before any file transfer, then the specified timeout will be applied to the new sockets opened for file transfer. As long as each read() call on the InputStream associated with the socket could return before timeout expired, you don't have to worry about the file size. On the other hand, if timeout did occurred, you would caught an exception and the thread would not block indefinitely.
精彩评论