1 // Copyright 2009 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.
13 // UDPAddr represents the address of a UDP end point.
19 // Network returns the address's network name, "udp".
20 func (a *UDPAddr) Network() string { return "udp" }
22 func (a *UDPAddr) String() string {
26 return JoinHostPort(a.IP.String(), itoa(a.Port))
29 // ResolveUDPAddr parses addr as a UDP address of the form
30 // host:port and resolves domain names or port names to
31 // numeric addresses on the network net, which must be "udp",
32 // "udp4" or "udp6". A literal IPv6 host address must be
33 // enclosed in square brackets, as in "[::]:80".
34 func ResolveUDPAddr(net, addr string) (*UDPAddr, os.Error) {
35 ip, port, err := hostPortToIP(net, addr)
39 return &UDPAddr{ip, port}, nil