# socket, bind, listen, accept from socket import * from struct import * import struct from sys import argv import threading class myThread(threading.Thread): def __init__(self, threadID, name, counter, cskt): threading.Thread.__init__(self) self.threadID = threadID self.name = name self.counter = counter self.cskt = cskt def run(self): cskt.send(struct.pack(" 1): port = int(argv[1]) skt.bind(("0.0.0.0", port)) skt.listen(5) threads = [] while(1): cskt, caddr = skt.accept() new_thread = myThread(len(threads), "Thread-" + str(len(threads)), len(threads), cskt) new_thread.start() threads.append(new_thread) # Wait for all threads to complete for t in threads: t.join() print("Exiting Main Thread")