You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
net: Listener.Addr reports port 0 after listening on port 0 #97
Listening on :0 asks the kernel for an ephemeral port, but the listener keeps the requested address, so ln.Addr() reports port 0. Binding an ephemeral port and then dialing ln.Addr() cannot work, which is the pattern httptest.NewServer uses.
The bound address needs to be read back from the socket after listen, through an optional interface so netdevs that cannot report it keep their current behavior. UDP is unaffected, because ListenUDP already fills in a port before binding.
Activity