OSDN Git Service

Update to current version of Go library.
[pf3gnuchains/gcc-fork.git] / libgo / go / net / lookup.go
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
5 package net
6
7 import (
8         "os"
9 )
10
11 // LookupHost looks up the given host using the local resolver.
12 // It returns an array of that host's addresses.
13 func LookupHost(host string) (addrs []string, err os.Error) {
14         addrs, err, ok := cgoLookupHost(host)
15         if !ok {
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)
27         }
28         return
29 }
30
31 // LookupPort looks up the port for the given network and service.
32 func LookupPort(network, service string) (port int, err os.Error) {
33         port, err, ok := cgoLookupPort(network, service)
34         if !ok {
35                 port, err = goLookupPort(network, service)
36         }
37         return
38 }
39
40 // LookupCNAME returns the canonical DNS host for the given name.
41 // Callers that do not care about the canonical name can call
42 // LookupHost or LookupIP directly; both take care of resolving
43 // the canonical name as part of the lookup.
44 func LookupCNAME(name string) (cname string, err os.Error) {
45         cname, err, ok := cgoLookupCNAME(name)
46         if !ok {
47                 cname, err = goLookupCNAME(name)
48         }
49         return
50 }