code: def get_port_stats(port):
      
      cnts = defaultdict(int)
      for c in psutil.net_connections():
          c_port = c.laddr[1]
          if c_port != port:
              continue
          status = c.status.lower()
          cnts[status] += 1
      return cnts
docs: Iterate over connections and count states for specified port
      :param port: port for which stats are collected
      :return: Counter with port states