LEFT | RIGHT |
| 1 // Copyright 2011 The Go Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style |
| 3 // license that can be found in the LICENSE file. |
| 4 |
1 package net | 5 package net |
2 | 6 |
3 import ( | 7 import ( |
4 "os" | 8 "os" |
5 ) | 9 ) |
6 | 10 |
7 // LookupHost looks for name using the local resolver. | 11 // LookupHost looks up the given host using the local resolver. |
8 // It returns an array of that host's addresses. | 12 // It returns an array of that host's addresses. |
9 func LookupHost(name string) (addrs []string, err os.Error) { | 13 func LookupHost(host string) (addrs []string, err os.Error) { |
10 » addrs, err, ok := cgoLookupHost(name) | 14 » addrs, err, ok := cgoLookupHost(host) |
11 if !ok { | 15 if !ok { |
12 » » addrs, err = goLookupHost(name) | 16 » » addrs, err = goLookupHost(host) |
| 17 » } |
| 18 » return |
| 19 } |
| 20 |
| 21 // LookupIP looks up host using the local resolver. |
| 22 // It returns an array of that host's IPv4 and IPv6 addresses. |
| 23 func LookupIP(host string) (addrs []IP, err os.Error) { |
| 24 » addrs, err, ok := cgoLookupIP(host) |
| 25 » if !ok { |
| 26 » » addrs, err = goLookupIP(host) |
13 } | 27 } |
14 return | 28 return |
15 } | 29 } |
16 | 30 |
17 // LookupPort looks up the port for the given network and service. | 31 // LookupPort looks up the port for the given network and service. |
18 func LookupPort(network, service string) (port int, err os.Error) { | 32 func LookupPort(network, service string) (port int, err os.Error) { |
19 port, err, ok := cgoLookupPort(network, service) | 33 port, err, ok := cgoLookupPort(network, service) |
20 if !ok { | 34 if !ok { |
21 port, err = goLookupPort(network, service) | 35 port, err = goLookupPort(network, service) |
22 } | 36 } |
23 return | 37 return |
24 } | 38 } |
25 | |
26 | |
27 // LookupIP resolves name using the DNS resolver. | |
28 // It returns an array of that host's IPv4 and IPv6 addresses. | |
29 func LookupIP(name string) (addrs []IP, err os.Error) { | |
30 addrs, err, ok := cgoLookupIP(name) | |
31 if !ok { | |
32 addrs, err = goLookupIP(name) | |
33 } | |
34 return | |
35 } | |
LEFT | RIGHT |