- take an input from the user until
\n
, then send the data to the server; - accept all the incoming messages from the server and write to the screen;
simultaneously?
Which are best practices?Thank you for your help.
—DonovanThreads are one implementation strategy for doing these things simultaneously. Twisted generally goes with another strategy - non-blocking I/O and an event multiplexer (eg select(2)).
If you want to handle input from stdin while you have a TCPServer running, all that means is that you want to use Twisted's APIs for reading from stdin, just like you're using Twisted's APIs for handling network connections.
See twisted.internet.stdio.StandardIO for that.
精彩评论