0

I'm a beginner in python. I need to write a multi-threaded version of this code in such a way that I do not define K1, K2, K3 and assign them ip address and port number manually. In fact, I want each of k1,k2,and k3 be replaced by a separate thread and I can create as many 'k' as possible with different ip address and port number. I made several attempts and still no results. I appreciate if any one can help or give me a clue.

here is the code:

def main():
    global k1,k2,k3
    k1.register_handler('BSSID', lambda *args, **kwargs: handle_bssid(**kwargs))
    k1.register_handler('SSID', lambda *args,**kwargs: handle_ssid(**kwargs))
    k2.register_handler('BSSID', lambda *args, **kwargs: handle_bssid(**kwargs))
    k2.register_handler('SSID', lambda *args,**kwargs: handle_ssid(**kwargs))
    k3.register_handler('BSSID', lambda *args, **kwargs: handle_bssid(**kwargs))
    k3.register_handler('SSID', lambda *args,**kwargs: handle_ssid(**kwargs))


    try:
        while True:
            k1.listen()
            k2.listen()
            k3.listen()
            handle_merge()
    except KeyboardInterrupt:
        pprint(k1.protocols)
        pprint(k2.protocols)
        pprint(k3.protocols)


if __name__ == '__main__':
    address1 = ('192.168.1.7', 2502)
    k1 = KismetClient(address1)
    address2 = ('192.168.1.16', 2502)
    k2 = KismetClient(address2)
    address3 = ('192.168.1.27', 2502)
    k3 = KismetClient(address3)
    main()
hyde
  • 60,639
  • 21
  • 115
  • 176
  • 2
    you should check out "Queue". This is a great tutorial learned from. https://pymotw.com/2/Queue/ – J'e Oct 17 '15 at 02:48
  • Your example code is incomplete. At the same time, it contains elements that are not necessary. Please extract a minimal example, and also make sure that you find out whether Kismet is actually required or not. – Ulrich Eckhardt Oct 17 '15 at 09:21

0 Answers0