setDataTimeout 何时被调用?
FTPClient (commons.net) 上的 setDataTimeout 何时调用?它是在套接字连接挂起时调用还是在达到超时值时调用?
例如。如果我将 setDataTimeout 设置为 30 秒,我不希望连接在大下载过程中 30 秒后断开。
When does 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该在任何文件传输之前调用 setDataTimeout,然后指定的超时将应用于为文件传输打开的新套接字。只要与套接字关联的 InputStream 上的每个 read() 调用都可以在超时到期之前返回,您就不必担心文件大小。另一方面,如果确实发生超时,您将捕获异常,并且线程不会无限期地阻塞。
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.