(port)
return cnts
Iterate over connections and count states for specified port
    :param port: port for which stats are collected
    :return: Counter with port states
Iterate over connections and count states for specified port
    :param port: port for which stats are collected
    :return: Counter with port states
Iterate over connections and count states for specified port : param port : port for which stats are collected : return : Counter with port states
def get_port_stats(port):
    """
    Iterate over connections and count states for specified port
    :param port: port for which stats are collected
    :return: Counter with port states
    """
    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
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