title: iOS TCP / IP Check connection
body: <p>I'm currently trying to connect to a tcp server. Everything works really good, but if the server is not available, the app freeze about 30 seconds and that's not really nice. I've searched for a resolution, but couldn't find something usefull so far.</p>
  
  <p>Maybe someone of you have got a solution to check a connection?</p>
  
  <pre><code>    CFReadStreamRef readStream;
      CFWriteStreamRef writeStream;
      CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)@"IP_SERVER_PATH", 6666, &amp;readStream, &amp;writeStream);
      inputStream = (__bridge NSInputStream *)readStream;
      outputStream = (__bridge NSOutputStream *)writeStream;
      [inputStream setDelegate:self];
      [outputStream setDelegate:self];
      [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
      [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
      [inputStream open];
      [outputStream open];
  </code></pre>