title: socket timeout value for iPhone app
body: <p>I'm writing iPhone application which uses sockets and uses <code>CFSocketConnectToAddress</code> for creating sockets. I need to specify socket timeout in seconds. What is best timeout value in seconds for iPhone/iPod which uses wifi/3g/edge connection ?</p>
  
  <p>Sample code:</p>
  
  <pre><code>#define SOCKET_TIMEOUT_VALUE ?
  CFSocketRef sock_id = CFSocketCreate(kCFAllocatorDefault, PF_INET,  SOCK_STREAM, IPPROTO_TCP, kCFSocketNoCallBack, NULL, NULL) ; 
  struct sockaddr_in addr4;
  memset(&amp;addr4, 0, sizeof(addr4));
  addr4.sin_len = sizeof(addr4);
  addr4.sin_family = PF_INET;
  addr4.sin_port = htons([[hostValue port_number] intValue]);
  inet_pton(AF_INET, inet_ntoa(*(struct in_addr *)host_name-&gt;h_addr_list[0]), &amp;addr4.sin_addr);
  CFDataRef addr = CFDataCreate(kCFAllocatorDefault, (void*)&amp;addr4, sizeof(struct sockaddr_in));
  int retVal = CFSocketConnectToAddress(sock_id, addr, SOCKET_TIMEOUT_VALUE);
  if (retVal != 0)
  {
      // Failed to Connect!
      errorNumber = FAILED_CONNECT ; 
      CFRelease(addr) ;
      CFRelease(sock_id) ;
      goto shutdown2; 
  }
  </code></pre>
  
  <p><a href="http://developer.apple.com/library/ios/#documentation/CoreFoundation/Reference/CFSocketRef/Reference/reference.html" rel="nofollow">Apple documentation for CFSocketConnectToAddress</a></p>
  
  <p>EDIT:</p>
  
  <p>App will have few socket creations same time for different hosts.</p>
  
  <p>Thanks</p>