I am trying to write a program that has clients connect to it while the server is still able to send commands to all of the clients. I am using the "Twisted" solution. How can I go about this? Here is the code I have so far (I understand that Twisted already uses non-blocking sockets):
import threading
print 'threading.'def dock():try:from twisted.internet.protocol import Factory, Protocolfrom twisted.internet import reactorimport currentTimeprint '[*]Imports succesful.'except:print '[/]Imports failed.'#Define the class for the protocolclass Master(Protocol):command = raw_input('> ')def connectionMade(self):print 'Slave connected.'print currentTime.getTime() #Print current time#self.transport.write("Hello")def connectionLost(self, reason):print 'Lost.'#Assemble it in a "factory"class MasterFactory(Factory):protocol = Masterreactor.listenTCP(8800, MasterFactory())#Run it allreactor.run()def commandline():raw_input('>')threading.Thread(target=dock()).start()
threading.Thread(target=commandline()).start()