code: def splitport (host, port=0):
      
      if ":" in host:
          shost, sport = host.split(":", 1)
          iport = is_numeric_port(sport)
          if iport:
              host, port = shost, iport
          elif not sport:
              # empty port, ie. the host was "hostname:"
              host = shost
          else:
              # For an invalid non-empty port leave the host name as is
              pass
      return host, port
docs: Split optional port number from host. If host has no port number,
      the given default port is returned.
  
      @param host: host name
      @ptype host: string
      @param port: the port number (default 0)
      @ptype port: int
  
      @return: tuple of (host, port)
      @rtype: tuple of (string, int)