Found the following chat server demo on Twisted's website:
factory = protocol.ServerFactory()
factory.protocol = SimpleLogger
factory.clients = []
application = service.Application("charServer")
internet.TCPServer(9999, factory).setServiceParent(application)
It didn't work in my project. It does not wait until the client connects to the server, but runs through the code and exits immediately. How can I fix this?
The lines above set up the connections to listen, but then immediately exit. You need to add something along the lines of:
if __name__ == '__main__':
from twisted.internet import reactor
reactor.run()