如题所述
1. org.apache.commons.net.ftp.FTPClient.setDataTimeout(int)
Sets the timeout in milliseconds to use when reading from the data connection.
设置读取数据传输超时时间
2. org.apache.commons.net.SocketClient.setSoTimeout(int)
Set the timeout in milliseconds of a currently open connection.
Only call this
method after a connection has been opened by connect().
setSoTimeout()这个方法所设置的超时时间还未结束的时候,可以通过socket.getInputStream()获得的InputStream对象进行二次读取。
在二次读取的时候,如果客户端如果没有进行二次请求,InputStream对象二次读取的时候会死锁,直到客户端二次请求时才会继续运行,但是一旦超过setSoTimeout()方法所设置的超时时间,便会抛出java.net.SocketTimeoutException: Read timed out异常。
也就是说两次请求间隔时间如果超过setSoTimeout()方法设置的超时时间,就会抛出异常,结束InputStream的二次读取
温馨提示:答案为网友推荐,仅供参考