mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net: fix Dial(":80") on Windows
Windows sockets allow bind to 0.0.0.0:80 but not connect to it.
To make Listen(":80") / Dial(":80") work as documented on Windows,
connect to 127.0.0.1 or ::1 (depending on network) in place of 0.0.0.0.
Fixes #6290.
Change-Id: Ia27537067276871648546678fbe0f1b8478329fe
Reviewed-on: https://go-review.googlesource.com/32101
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
This commit is contained in:
parent
c56cc9b3b5
commit
1a0b1cca4c
8 changed files with 46 additions and 0 deletions
|
|
@ -55,6 +55,23 @@ func TestProhibitionaryDialArg(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestDialLocal(t *testing.T) {
|
||||
ln, err := newLocalListener("tcp")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer ln.Close()
|
||||
_, port, err := SplitHostPort(ln.Addr().String())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, err := Dial("tcp", JoinHostPort("", port))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c.Close()
|
||||
}
|
||||
|
||||
func TestDialTimeoutFDLeak(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "plan9":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue