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()