Index: src/pkg/net/ipsock.go |
=================================================================== |
--- a/src/pkg/net/ipsock.go |
+++ b/src/pkg/net/ipsock.go |
@@ -170,9 +170,10 @@ |
return nil, InvalidAddrError("unexpected socket family") |
} |
-// Split "host:port" into "host" and "port". |
-// Host cannot contain colons unless it is bracketed. |
-func splitHostPort(hostport string) (host, port string, err os.Error) { |
+// SplitHostPort splits a network address of the form |
+// "host:port" or "[host]:port" into host and port. |
+// The latter form must be used when host contains a colon. |
+func SplitHostPort(hostport string) (host, port string, err os.Error) { |
// The port starts after the last colon. |
i := last(hostport, ':') |
if i < 0 { |
@@ -195,9 +196,9 @@ |
return |
} |
-// Join "host" and "port" into "host:port". |
-// If host contains colons, will join into "[host]:port". |
-func joinHostPort(host, port string) string { |
+// JoinHostPort combines host and port into a network address |
+// of the form "host:port" or, if host contains a colon, "[host]:port". |
+func JoinHostPort(host, port string) string { |
// If host has colons, have to bracket it. |
if byteIndex(host, ':') >= 0 { |
return "[" + host + "]:" + port |
@@ -207,7 +208,7 @@ |
// Convert "host:port" into IP address and port. |
func hostPortToIP(net, hostport string) (ip IP, iport int, err os.Error) { |
- host, port, err := splitHostPort(hostport) |
+ host, port, err := SplitHostPort(hostport) |
if err != nil { |
goto Error |
} |
@@ -218,7 +219,7 @@ |
addr = ParseIP(host) |
if addr == nil { |
// Not an IP address. Try as a DNS name. |
- _, addrs, err1 := LookupHost(host) |
+ addrs, err1 := LookupHost(host) |
if err1 != nil { |
err = err1 |
goto Error |