title: TLS connection problem in iOS due to Socket File descriptor value increase more than 1023
body: <p>We are using RESIProcate Lib in iOS, here in socket.hxx select() was used for getting FD value.
  we are facing issue that FD value is getting increased in every new TLS connection establishment.</p>
  <p>socket.hxx --&gt;&gt; <a href="https://github.com/resiprocate/resiprocate/blob/master/rutil/Socket.hxx" rel="nofollow noreferrer">https://github.com/resiprocate/resiprocate/blob/master/rutil/Socket.hxx</a></p>
  <pre><code>int select(struct timeval&amp; tv)
  {
  return numReady = ::select(size, &amp;read, &amp;write, &amp;except, &amp;tv);
  }
  
  int selectMilliSeconds(unsigned long ms)
  {
  struct timeval tv;
  tv.tv_sec = (ms/1000);
  tv.tv_usec = (ms%1000)*1000;
  return select(tv);
  }
  </code></pre>
  <p>from Linux manual it is written that:
  select() can monitor only file descriptors numbers that are less than FD_SETSIZE (1024)—an unreasonably low limit for many modern applications—and this limitation will not change.
  (<a href="https://www.man7.org/linux/man-pages/man2/select.2.html" rel="nofollow noreferrer">https://www.man7.org/linux/man-pages/man2/select.2.html</a>)</p>
  <p>we faced this problem with iOS platform. when size param in select() is getting more that 1024 value.</p>
  <p>due to this:</p>
  <pre><code>resip_assert(read.fd_count &lt; FD_SETSIZE); // Ensure there is room to add new FD
  #endif
  FD_SET(fd, &amp;read);
  size = ( int(fd+1) &gt; size) ? int(fd+1) : size;
  </code></pre>
  <p>tls connection is getting interrupted and not proceeding further.</p>
  <p>So is there any way in the current resip to overcome this situation if FD value becomes more than 1023?</p>
  <p>in internalTransport.cxx -&gt; <code>fd = ::socket(ipVer == V4 ? PF_INET : PF_INET6, SOCK_STREAM, 0);</code></p>
  <p>when fd is becoming more than 1023, we are facing the above-mentioned problem.
  Is there any way to control this value so that it may always stay under 1023 in iOS?</p>
  <p>one more thing:
  is there any relation with server and client connection time period, which may cause the FD value increase on the client side in each new set of TCP/TLS connections by using the socket method even though the previous socket was closed?</p>