Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
net: pass SO_REUSEADDR sockopt when establishing TCP connection if local IP address is set #9929
Currently go apps are limited by 64K outgoing connections when running on hosts with multiple IP addresses if local IP address is passed to net.DialTCP(). This limit can be eliminated when setting SO_REUSEADDR sockopt to the socket before connection establishing according to https://idea.popcount.org/2014-04-03-bind-before-connect/ . Below are the corresponding quotes from the article:
Yup, TCP's simultaneous connections and derived techniques such as hole-punching are fun.
I have no concrete opinion on this stuff unless it harms, a) the top-half stuff of user IPC subsystem inside kernel, which handles bump-in-the-API mech for dual IP stack on some platform, b) the bottom-half stuff of user IPC subsystem inside kernel, which takes care of protocol integration including destination/source address selection by using IP routing/prefix lookup.
Perhaps, it may be fine on all the supported platforms, not sure. If you want to try a contribution (writing a patch and pushing it down to review process), please include a few test cases that satisfy the point of views above; both dual IP stack and IP routing behavior--from unspecified addresses (0.0.0.0 or ::) to specified addresses for source and/or destination address selection with validating IP address reachability.