code: def splitnport(host, defport=-1):
      
      global _nportprog
      if _nportprog is None:
          import re
          _nportprog = re.compile('^(.*):(.*)$')
  
      match = _nportprog.match(host)
      if match:
          host, port = match.group(1, 2)
          try:
              if not port: raise ValueError("no digits")
              nport = int(port)
          except ValueError:
              nport = None
          return host, nport
      return host, defport
docs: Split host and port, returning numeric port.
      Return given default port if no ':' found; defaults to -1.
      Return numerical port if a valid number are found after ':'.
      Return None if ':' but not a valid number.