import re


def ParseHostPort(address):
  """Parses the provided address string as host:port and
  returns a tuple of (str host, int port).
  """
  host_port_re = re.match(r"([a-zA-Z0-9-\.]+):([0-9]{1,5})$", address)
  if not host_port_re:
    raise TypeError("bad host:port: %s" % address)
  host = host_port_re.group(1)
  port = int(host_port_re.group(2))
  if port >= 65536:
    raise TypeError("invalid port: %d" % port)
  return (host, port)