possible causes for EADDRINUSE in client code
Hi!
I'm running a 2.6.26 kernel where I have to create short-lived TCP connections with a high frequency. In order to do this, I am using non-blocking sockets which are bound to different IP addresses in a round-robin manner, and to port 0, so the kernel can choose a free local port.
Now I observed that I am getting EADDRINUSE errors on the bind system call, even though there should be ports left according to the current net.ipv4.ip_local_port_range sysctl setting.
I tried to enumerate the used ports at the time of the error using netstat, which shows only rather few ports being in use, but I realize that this is an inaccurate measure because it takes time for netstat to be forked and run.
What I wonder is: Is there any limit beyond net.ipv4.ip_local_port_range which may lead to EADDRINUSE errors? Maybe any limits in the kernel data structures I should be aware of when working with huge amounts of TCP connections?
Thanks!
--
Steven