Hi,
I have made simple test case to test this fix.
I'm sorry to say that the fix doesn't work.
connected() method still returns true although server is killed while connection is open.
Sample code:
-----------------------------------------------------------
import com.enterprisedt.net.ftp.FTPException;
public class Test {
Test() {
try {
FTP ftp = new FTP();
ftp.connect();
try {
System.out.println("Sleeping one minute.... Kill ftp server process now!!");
Thread.sleep(60000);
} catch (InterruptedException e) {}
System.out.println("------>" + ftp.connected());
ftp.disconnected();
} catch (FTPException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new Test();
}
}
-----------------------------------------------------------------------------
import java.io.IOException;
import com.enterprisedt.net.ftp.FTPClient;
import com.enterprisedt.net.ftp.FTPException;
public class FTP {
FTPClient ftpClient = null;
FTP() throws FTPException {
ftpClient = new FTPClient();
try {
ftpClient.setRemoteHost("10.10.10.10");
ftpClient.setRemotePort(21);
ftpClient.setTimeout(20000);
} catch (IOException e) {
throw new FTPException(e.getMessage());
}
}
public void connect() throws FTPException {
try {
ftpClient.connect();
ftpClient.login("yyyyyyyyyyy", "xxxxxx");
String[] dirList = ftpClient.dir(".");
for (int i = 0; i < dirList.length; i++) {
System.out.println(dirList[i]);
}
} catch (IOException e) {
throw new FTPException(e.getMessage());
}
}
public boolean connected() {
return ftpClient.connected();
}
public void disconnected() throws FTPException {
try {
ftpClient.quit();
} catch (IOException e) {
throw new FTPException(e.getMessage());
}
}
}
----------------------------------------------------------------------------------------[/code]