开发者

When is the setDataTimeout called?

开发者 https://www.devze.com 2023-03-08 10:34 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消