On Fri, 27 Aug 2004, Martijn van Oosterhout wrote:
If you're connecting to different places, you might be able to use SO_REUSEPORT. That avoids the TIME_WAIT problem for incoming connections anyway....
My problem is outgoing connections... The server side has absolutely no problem with TCP ports.
After all, for TCP you're not required to have unique addr:port on your end, just as long as the remote end is different...
Problem is that with Linux unless the application manually binds the local end when making an outgoing connection you are limited to at most ca 60K connections including TIME_WAIT:s.. This is only good for up to ca 1K connections/s, less if the connections require more than a second each. (1 minute TIME_WAIT in Linux)
Anyway, I now have the application modified to do an explicit bind using a range of local IP addresses eleminating the need for the kernel to assign a source port. This way this limitation of the Linux TCP kernel is avoided.
I looked into if the Linux kernel could be fixed easily, but it appears the outgoing address:port assignment is limited by design to only assign one at a time (first source port, then source address) making this very hard to correct without kernel API changes.
Regards Henrik - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html