import psutil
    
def get_connection_from(address):
    connections = []
    
    res = psutil.net_connections("tcp")
    for r in res:
        # do nothing for empty and not macthing address
        if not r.raddr or r.raddr[0] != address:
            continue
        
        sc ={}
        try:
            sc['dest_port'] = r.laddr[1]
            sc['dest_addr'] = r.laddr[0]
            sc['src_port'] = r.raddr[1]
            sc['src_addr'] = r.raddr[0]
            sc['status'] = r.status
            sc['pid'] = r.pid
            connections.append(sc)
        except:
            pass
        
    return connections
        

res = get_connection_from('192.168.1.79')
for c in res:
    print("Source Port: %s,  Dest Port: %s, Source Address: %s, Dest Address: %s, Pid: %s, Status: %s "%(c['src_port'], c['dest_port'], c['src_addr'], c['dest_addr'], c['pid'], c['status']))
043925ce75dc5479f0ec050a485f063d6f5fb789
<mask token>

<mask token>


def get_connection_from(address):
    connections = []
    res = psutil.net_connections('tcp')
    for r in res:
        if not r.raddr or r.raddr[0] != address:
            continue
        sc = {}
        try:
            sc['dest_port'] = r.laddr[1]
            sc['dest_addr'] = r.laddr[0]
            sc['src_port'] = r.raddr[1]
            sc['src_addr'] = r.raddr[0]
            sc['status'] = r.status
            sc['pid'] = r.pid
            connections.append(sc)
        except:
            pass
    return connections


<mask token>
for c in res:
    print(
        'Source Port: %s,  Dest Port: %s, Source Address: %s, Dest Address: %s, Pid: %s, Status: %s '
         % (c['src_port'], c['dest_port'], c['src_addr'], c['dest_addr'], c
        ['pid'], c['status']))

<mask token>


def get_connection_from(address):
    connections = []
    res = psutil.net_connections('tcp')
    for r in res:
        if not r.raddr or r.raddr[0] != address:
            continue
        sc = {}
        try:
            sc['dest_port'] = r.laddr[1]
            sc['dest_addr'] = r.laddr[0]
            sc['src_port'] = r.raddr[1]
            sc['src_addr'] = r.raddr[0]
            sc['status'] = r.status
            sc['pid'] = r.pid
            connections.append(sc)
        except:
            pass
    return connections


res = get_connection_from('192.168.1.79')
for c in res:
    print(
        'Source Port: %s,  Dest Port: %s, Source Address: %s, Dest Address: %s, Pid: %s, Status: %s '
         % (c['src_port'], c['dest_port'], c['src_addr'], c['dest_addr'], c
        ['pid'], c['status']))

import psutil


def get_connection_from(address):
    connections = []
    res = psutil.net_connections('tcp')
    for r in res:
        if not r.raddr or r.raddr[0] != address:
            continue
        sc = {}
        try:
            sc['dest_port'] = r.laddr[1]
            sc['dest_addr'] = r.laddr[0]
            sc['src_port'] = r.raddr[1]
            sc['src_addr'] = r.raddr[0]
            sc['status'] = r.status
            sc['pid'] = r.pid
            connections.append(sc)
        except:
            pass
    return connections


res = get_connection_from('192.168.1.79')
for c in res:
    print(
        'Source Port: %s,  Dest Port: %s, Source Address: %s, Dest Address: %s, Pid: %s, Status: %s '
         % (c['src_port'], c['dest_port'], c['src_addr'], c['dest_addr'], c
        ['pid'], c['status']))

import psutil
    
def get_connection_from(address):
    connections = []
    
    res = psutil.net_connections("tcp")
    for r in res:
        # do nothing for empty and not macthing address
        if not r.raddr or r.raddr[0] != address:
            continue
        
        sc ={}
        try:
            sc['dest_port'] = r.laddr[1]
            sc['dest_addr'] = r.laddr[0]
            sc['src_port'] = r.raddr[1]
            sc['src_addr'] = r.raddr[0]
            sc['status'] = r.status
            sc['pid'] = r.pid
            connections.append(sc)
        except:
            pass
        
    return connections
        

res = get_connection_from('192.168.1.79')
for c in res:
    print("Source Port: %s,  Dest Port: %s, Source Address: %s, Dest Address: %s, Pid: %s, Status: %s "%(c['src_port'], c['dest_port'], c['src_addr'], c['dest_addr'], c['pid'], c['status']))