What is the purpose if this patch, does it fix any real application?
I ran into this with a program I was writing myself; I have not encountered this issue in any existing programs.
The meaning of that test is that with SO_REUSADDR on Windows multiple sockets can be bound to the same address, and a newly bound socket may actually receive connection on it, either at once or when the other socket will be closed.
The behavior is stated to be indeterminate when two sockets are bound to the same interface and port, unless they are multicast sockets. However, it appears to be consistent that the socket to bind first is prioritized for most operations.
Maybe it is possible to achieve with Linux SO_REUSEPORT and BPF filters, but probably not by ignoring an error on listen.
Certainly the patch was insufficient at first. I didn't quite understand how `SO_REUSEADDR` works on Windows and made assumptions based on the unit tests. `SO_REUSEPORT` would unfortunately not fully work because it explicitly avoids specific behaviors that Windows allows.
---
After experimenting a lot with various edge cases, the patch in its current state does lack some behavior that Windows exhibits, most notably allowing binding to an address after another socket has begun listening on it. I still need to write tests and ensure that send and recv work accurately, but I have a good idea of how to accommodate this quirk.