def _parse_tcp_line(line):
    '''
    Parse a single line from the contents of /proc/net/tcp or /proc/net/tcp6
    '''
    ret = {}
    comps = line.strip().split()
    sl = comps[0].rstrip(':')
    ret[sl] = {}
    l_addr, l_port = comps[1].split(':')
    r_addr, r_port = comps[2].split(':')
    ret[sl]['local_addr'] = hex2ip(l_addr, True)
    ret[sl]['local_port'] = int(l_port, 16)
    ret[sl]['remote_addr'] = hex2ip(r_addr, True)
    ret[sl]['remote_port'] = int(r_port, 16)
    ret[sl]['state'] = int(comps[3], 16)
    return ret
Parse a single line from the contents of /proc/net/tcp or /proc/net/tcp6