Every FTP command can throw an FTPException or an IOException.
It simply isn't possible for a client to detect all instances when a server might have gone away - even Select() can't do that.
If the server is timing out the client, set the idle timeout to be 30s - if you want to stay connected.
Normally with FTP, it is best to login, do your stuff and logout. Maintaining a connection is not a good idea.