OLD | NEW |
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 "os" | 8 "os" |
9 "reflect" | 9 "reflect" |
10 "runtime" | 10 "runtime" |
11 "syscall" | 11 "syscall" |
12 "testing" | 12 "testing" |
13 ) | 13 ) |
14 | 14 |
15 type listenerFile interface { | 15 type listenerFile interface { |
16 Listener | 16 Listener |
17 » File() (f *os.File, err os.Error) | 17 » File() (f *os.File, err error) |
18 } | 18 } |
19 | 19 |
20 type packetConnFile interface { | 20 type packetConnFile interface { |
21 PacketConn | 21 PacketConn |
22 » File() (f *os.File, err os.Error) | 22 » File() (f *os.File, err error) |
23 } | 23 } |
24 | 24 |
25 type connFile interface { | 25 type connFile interface { |
26 Conn | 26 Conn |
27 » File() (f *os.File, err os.Error) | 27 » File() (f *os.File, err error) |
28 } | 28 } |
29 | 29 |
30 func testFileListener(t *testing.T, net, laddr string) { | 30 func testFileListener(t *testing.T, net, laddr string) { |
31 if net == "tcp" { | 31 if net == "tcp" { |
32 laddr += ":0" // any available port | 32 laddr += ":0" // any available port |
33 } | 33 } |
34 l, err := Listen(net, laddr) | 34 l, err := Listen(net, laddr) |
35 if err != nil { | 35 if err != nil { |
36 t.Fatalf("Listen failed: %v", err) | 36 t.Fatalf("Listen failed: %v", err) |
37 } | 37 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 if supportsIPv6 { | 129 if supportsIPv6 { |
130 testFilePacketConnListen(t, "udp", "[::1]:0") | 130 testFilePacketConnListen(t, "udp", "[::1]:0") |
131 } | 131 } |
132 if supportsIPv6 && supportsIPv4map { | 132 if supportsIPv6 && supportsIPv4map { |
133 testFilePacketConnDial(t, "udp", "[::ffff:127.0.0.1]:12345") | 133 testFilePacketConnDial(t, "udp", "[::ffff:127.0.0.1]:12345") |
134 } | 134 } |
135 if syscall.OS == "linux" { | 135 if syscall.OS == "linux" { |
136 testFilePacketConnListen(t, "unixgram", "@gotest1/net") | 136 testFilePacketConnListen(t, "unixgram", "@gotest1/net") |
137 } | 137 } |
138 } | 138 } |
OLD | NEW |