python twisted stdio multiple connections to a server with a command prompt for interaction
I have written a simple twisted application that connects to a server that listens on 1 or more ports开发者_运维知识库. The twisted app connects to this server and usually connects to a few of the open ports at a time. This server is a serial logger that connects to serial devices and provides the serial line information through a raw TCP Socket and I need to log all this data to disk.
My current app logs any received information to disk without issue.
What I now need to do but am unable to make progress on is add the ability to interact with my application through stdin. I need to be able to issue commands to the local application but also send text commands through the connected sockets.
I have a basic prompt using basic.LineReceiver and adding this to my reactor but can't figure out how to send the data to the server or even if this is the correct way of doing this.
A simplified example would be helpful to show what I need to do.
Thanks
J
To add an interactive console to your Twisted app, see this article -- it explains how to use twisted.internet.stdio for the purpose.
精彩评论