I have mad an program that search an FTP server for files and if the file I'm looking for isn't there I transfer it to the FTPserver. Sometimes it works and sometimes it doesn't!

I'm getting this error:
12031 (Connection with the server has been reset.)
And the file I want to transfer isn't transfered.

What can I do to get around this?

Please help!