Commit 6716a54e authored by Mikio Hara's avatar Mikio Hara

net: make newLocalListener handle network argument correcly

Change-Id: I8987e705af069846e6668e2f2104e0254e695139
Reviewed-on: https://go-review.googlesource.com/19706
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 9194421e
......@@ -30,10 +30,20 @@ func testUnixAddr() string {
func newLocalListener(network string) (Listener, error) {
switch network {
case "tcp", "tcp4", "tcp6":
case "tcp":
if supportsIPv4 {
if ln, err := Listen("tcp4", "127.0.0.1:0"); err == nil {
return ln, nil
}
}
if supportsIPv6 {
return Listen("tcp6", "[::1]:0")
}
case "tcp4":
if supportsIPv4 {
return Listen("tcp4", "127.0.0.1:0")
}
case "tcp6":
if supportsIPv6 {
return Listen("tcp6", "[::1]:0")
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment