Support for IPv6 servers

When a host resolves to an IPv6 address, net.Dial to "addr:port" fails
with "too many colons in address" as the address needs to be enclosed in
square brackets. Use net.JoinHostPort to join them correctly.

Additionally, support square brackets (although not strictly necessary)
in the host specification.