Most probably server is simply closing connection when it is inactive for some time. From what I see in the ftp tutorial, initializing ftp is NOT connecting to the server. Connection is done when an operation is requested, at least so I understood from the tutorial.
Anyway, I would firstly place all of my ftp requests in a list, then remove each one when succeeded. If failed and the error is that server closed communication, I would probably choose to close ftp, re-initialize it and restart the remaining requests. Just a thought.