'TLS connection problem in iOS due to Socket File descriptor value increase more than 1023
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.
socket.hxx -->> https://github.com/resiprocate/resiprocate/blob/master/rutil/Socket.hxx
int select(struct timeval& tv)
{
return numReady = ::select(size, &read, &write, &except, &tv);
}
int selectMilliSeconds(unsigned long ms)
{
struct timeval tv;
tv.tv_sec = (ms/1000);
tv.tv_usec = (ms%1000)*1000;
return select(tv);
}
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. (https://www.man7.org/linux/man-pages/man2/select.2.html)
we faced this problem with iOS platform. when size param in select() is getting more that 1024 value.
due to this:
resip_assert(read.fd_count < FD_SETSIZE); // Ensure there is room to add new FD
#endif
FD_SET(fd, &read);
size = ( int(fd+1) > size) ? int(fd+1) : size;
tls connection is getting interrupted and not proceeding further.
So is there any way in the current resip to overcome this situation if FD value becomes more than 1023?
in internalTransport.cxx -> fd = ::socket(ipVer == V4 ? PF_INET : PF_INET6, SOCK_STREAM, 0);
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?
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?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
