[Twisted-Python] nonblocking stdio

Sir.shz sir.shz at gmail.com
Wed Apr 27 19:59:56 EDT 2005


Hi, I'm trying to write a test tcp client which sends some commands to the
server, I'd like the
client to take the commands from stdin, and sends it to the server. The
following code segment
doesn't seem to send anything, is it because the while loop is actually
blocking? what's the right way to
accomplish this? Thanks.

Z.

class MyClientProtocol(basic.LineReceiver):
     def lineReceived(self,data):
          stdout.write("From Server:" + data+"\n"),

     def connectionMade(self):
           while True:
                cmd = raw_input("Enter command:")
                self.transport.write(cmd+"\r\n")







More information about the Twisted-Python mailing list