code: def addr_tuple(s):
      
      if "[" in s:
          # ip v6
          if (s.count("[") != 1) or (s.count("]") != 1):
              raise ValueError("Invalid IPv6 address!")
          end = s.index("]")
          if ":" not in s[end:]:
              raise ValueError("IPv6 address does specify a port to use!")
          host, port = s[1:end], s[end+1:]
          port = int(port)
          return (host, port)
      else:
          host, port = s.split(":")
          port = int(port)
          return (host, port)
docs: converts a string into a tuple of (host, port)