Skip to content

connect: On linux, set the IP_BIND_ADDRESS_NO_PORT sockopt if supported

The linux kernel can defer port selection to the connect stage by setting IP_BIND_ADDRESS_NO_PORT if source port zero, at that point the full 4-tuple is known and the source port can be shared, otherwise it must be reserved at bind() time and the source port choice gets limited to around 32K minus all ports already reserved or in use by the system. On a loaded machine the number can be very small and result in port exhaustion.

The second patch removes the arbitrary limit of 10 connections in the listen backlog, defering to the operating system what the actual limit is.

Merge request reports