net: protocol family adaptive address family selection

This CL will help to make an adaptive address family
selection possible when an any address family, vague
network string such as "ip", "tcp" or "udp" is passed
to Dial and Listen API.

Fixes #1769.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4438066
This commit is contained in:
Mikio Hara 2011-05-16 17:03:06 -04:00 committed by Russ Cox
parent b701cf3332
commit 2ddcad96d7
11 changed files with 183 additions and 95 deletions

View file

@ -62,7 +62,7 @@ func TestFileListener(t *testing.T) {
}
testFileListener(t, "tcp", "127.0.0.1")
testFileListener(t, "tcp", "127.0.0.1")
if kernelSupportsIPv6() {
if supportsIPv6 && supportsIPv4map {
testFileListener(t, "tcp", "[::ffff:127.0.0.1]")
testFileListener(t, "tcp", "127.0.0.1")
testFileListener(t, "tcp", "[::ffff:127.0.0.1]")
@ -121,8 +121,10 @@ func TestFilePacketConn(t *testing.T) {
}
testFilePacketConnListen(t, "udp", "127.0.0.1:0")
testFilePacketConnDial(t, "udp", "127.0.0.1:12345")
if kernelSupportsIPv6() {
if supportsIPv6 {
testFilePacketConnListen(t, "udp", "[::1]:0")
}
if supportsIPv6 && supportsIPv4map {
testFilePacketConnDial(t, "udp", "[::ffff:127.0.0.1]:12345")
}
if syscall.OS == "linux" {