LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package net | 5 package net |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "os" | 9 "os" |
10 "runtime" | 10 "runtime" |
11 "testing" | 11 "testing" |
12 ) | 12 ) |
13 | 13 |
14 var ipv4MulticastListenerTests = []struct { | 14 var ipv4MulticastListenerTests = []struct { |
15 net string | 15 net string |
16 gaddr *UDPAddr // see RFC 4727 | 16 gaddr *UDPAddr // see RFC 4727 |
17 }{ | 17 }{ |
18 {"udp", &UDPAddr{IP: IPv4(224, 0, 0, 254), Port: 12345}}, | 18 {"udp", &UDPAddr{IP: IPv4(224, 0, 0, 254), Port: 12345}}, |
19 | 19 |
20 {"udp4", &UDPAddr{IP: IPv4(224, 0, 0, 254), Port: 12345}}, | 20 {"udp4", &UDPAddr{IP: IPv4(224, 0, 0, 254), Port: 12345}}, |
21 } | 21 } |
22 | 22 |
23 // TestIPv4MulticastListener tests both single and double listen to a | 23 // TestIPv4MulticastListener tests both single and double listen to a |
24 // test listener with same address family, same group address and same | 24 // test listener with same address family, same group address and same |
25 // port. | 25 // port. |
26 func TestIPv4MulticastListener(t *testing.T) { | 26 func TestIPv4MulticastListener(t *testing.T) { |
27 switch runtime.GOOS { | 27 switch runtime.GOOS { |
28 case "windows": | |
29 if testing.Short() || !*testExternal { | |
30 t.Skipf("skipping test on %q to avoid network firewall",
runtime.GOOS) | |
31 } | |
32 case "plan9": | 28 case "plan9": |
33 t.Skipf("skipping test on %q", runtime.GOOS) | 29 t.Skipf("skipping test on %q", runtime.GOOS) |
34 } | 30 } |
35 | 31 |
36 closer := func(cs []*UDPConn) { | 32 closer := func(cs []*UDPConn) { |
37 for _, c := range cs { | 33 for _, c := range cs { |
38 if c != nil { | 34 if c != nil { |
39 c.Close() | 35 c.Close() |
40 } | 36 } |
41 } | 37 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 return false, err | 175 return false, err |
180 } | 176 } |
181 for _, ifma := range ifmat { | 177 for _, ifma := range ifmat { |
182 if ifma.(*IPAddr).IP.Equal(ip) { | 178 if ifma.(*IPAddr).IP.Equal(ip) { |
183 return true, nil | 179 return true, nil |
184 } | 180 } |
185 } | 181 } |
186 } | 182 } |
187 return false, nil | 183 return false, nil |
188 } | 184 } |
LEFT | RIGHT |