(kind, _pid=-1)
return list(ret)
Return socket connections.  If pid == -1 return system-wide
    connections (as opposed to connections opened by one process only).
    Only INET sockets are returned (UNIX are not).
Return socket connections.  If pid == -1 return system-wide
    connections (as opposed to connections opened by one process only).
    Only INET sockets are returned (UNIX are not).
Return socket connections . If pid == - 1 return system - wide connections ( as opposed to connections opened by one process only ) . Only INET sockets are returned ( UNIX are not ) .
def net_connections(kind, _pid=-1):
    """Return socket connections.  If pid == -1 return system-wide
    connections (as opposed to connections opened by one process only).
    Only INET sockets are returned (UNIX are not).
    """
    cmap = _common.conn_tmap.copy()
    if _pid == -1:
        cmap.pop('unix', 0)
    if kind not in cmap:
        raise ValueError("invalid %r kind argument; choose between %s"
                         % (kind, ', '.join([repr(x) for x in cmap])))
    families, types = _common.conn_tmap[kind]
    rawlist = cext.net_connections(_pid, families, types)
    ret = set()
    for item in rawlist:
        fd, fam, type_, laddr, raddr, status, pid = item
        if fam not in families:
            continue
        if type_ not in types:
            continue
        status = TCP_STATUSES[status]
        fam = sockfam_to_enum(fam)
        type_ = socktype_to_enum(type_)
        if _pid == -1:
            nt = _common.sconn(fd, fam, type_, laddr, raddr, status, pid)
        else:
            nt = _common.pconn(fd, fam, type_, laddr, raddr, status)
        ret.add(nt)
    return list(ret)
def net_connections ( kind , _pid = - 1 ) : cmap = _common . conn_tmap . copy ( ) if _pid == - 1 : cmap . pop ( 'unix' , 0 ) if kind not in cmap : raise ValueError ( "invalid %r kind argument; choose between %s" % ( kind , ', ' . join ( [ repr ( x ) for x in cmap ] ) ) ) families , types = _common . conn_tmap [ kind ] rawlist = cext . net_connections ( _pid , families , types ) ret = set ( ) for item in rawlist : fd , fam , type_ , laddr , raddr , status , pid = item if fam not in families : continue if type_ not in types : continue status = TCP_STATUSES [ status ] fam = sockfam_to_enum ( fam ) type_ = socktype_to_enum ( type_ ) if _pid == - 1 : nt = _common . sconn ( fd , fam , type_ , laddr , raddr , status , pid ) else : nt = _common . pconn ( fd , fam , type_ , laddr , raddr , status ) ret . add ( nt ) return list ( ret )