iosftpnsrunloopnsinputstreamnsoutputstream

unable to forcefully cancel ftp download


I am using SimpleFTPSample to download and upload from FTP server. I have to cancel download after specific time regardless of completion and start uploading. But If I cancel the download and then start upload delegate method stream:handleEvent: is not getting called. Delegate method is getting called if upload starts after download completion.

I am unable to understand the reason. I am creating separate connection for both task.

Since we need to schedule runloop to work with network stream and runloop is not exiting when we forcefully cancel the download, is this the reason?

Do I need to start both operation in separate thread, so that I can start uploading after specific time?


Solution

  • I am able to solve my problem by setting kCFStreamPropertyFTPAttemptPersistentConnection property to kCFBooleanFalse. By default this property is true and hence connection doesn't break if we forcefully close it. Actual credit goes to this guy who had given the answer.