Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS nkreipke/FTPManager : how to reduce timeout?
    primarykey
    data
    text
    <p>I've recently posted a question about reducing the timeout of an FTP connection (<a href="https://stackoverflow.com/questions/19292936/ios-how-to-reduce-an-ftp-connection-timeout">click here to see it if you want</a>).</p> <p>Now, I've been asked to post a more specific question, focusing on the component we're using for the FTP download.</p> <p>We're using Nico Kreipke's FTPManager (<a href="https://github.com/nkreipke/FTPManager" rel="nofollow noreferrer">click here to go to its GitHub</a>).</p> <p>What we're trying to implement is to download data from an FTP address, and if it fails we'll fallback to use an HTTPS web server.</p> <p>When the FTP address we give isn't available, it takes about one minute to timeout.</p> <p>The question is, how can I reduce that timeout?</p> <p>Best regards,<br/> Tiago</p> <p><strong>Some More Info</strong></p> <p>I forgot to say, the FTP connection is done with an IP (local network).</p> <p><strong>Johan's Tip</strong></p> <p>I added a property to FTPManager, a <code>double</code> named <code>timeout</code>.</p> <p>Then I've overridden the accessor of <code>serverReadStream</code>, a property used throughout FTPManager to hold the read stream, so that it would configure the timeout interval for all requests.</p> <pre><code>- (NSInputStream *)serverReadStream { return _serverReadStream; } - (void)setServerReadStream:(NSInputStream *)serverReadStream { if ((_serverReadStream = serverReadStream)) { CFNumberRef number = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &amp;_timeout); CFReadStreamSetProperty((__bridge CFReadStreamRef)(_serverReadStream), _kCFStreamPropertyReadTimeout, number); CFRelease(number); } } </code></pre> <p><code>_kCFStreamPropertyReadTimeout</code> is defined by:</p> <pre><code>#define _kCFStreamPropertyReadTimeout CFSTR("_kCFStreamPropertyReadTimeout") </code></pre> <p>However, it still takes about one minute to timeout. I set the timeout before connecting to the FTP address, right after creating <code>ftpManager</code>. The code I use to set the timeout follows:</p> <pre><code>FTPManager *ftpManager = [[FTPManager alloc] init]; [ftpManager setTimeout:10]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload