Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(14)

Unified Diff: src/pkg/net/ipsock.go

Issue 4244055: code review 4244055: net: drop laddr from Dial, cname from LookupHost; new f... (Closed)
Patch Set: diff -r 8b9c0b903333 https://go.googlecode.com/hg/ Created 13 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/net/iprawsock.go ('k') | src/pkg/net/lookup.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/pkg/net/iprawsock.go ('k') | src/pkg/net/lookup.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b