[Twisted-Python] getting sshsimpleserver.py to work within a wrapper

Ben Hyde bhyde at pobox.com
Tue Mar 10 10:39:10 EDT 2009

On Mar 10, 2009, at 10:16 AM, jkv wrote:
> Hi,
> I just recently got aware of twisted and im currently playing around  
> with it.
> Is there any way to make reactor.listen listen on stdio instead of a  
> real network connection?
> In  one of the examples (sshsimpleserver.py) reactor.listenTCP is  
> used to listen on the network socket, as far as i can read from the  
> twisted core documentation there are no builtin way to make  
> reactor.listen* listen on stdin instead... Any hints?

Take look at twisted.internet.stdio.StandardIO.

I'm new to this twisted stuff, so no doubt I've gotten this a bit  
wrong... but:

But, the act of listening is primarily about waiting for a new  
connection etc.; since standard io is already connected it doesn't  
quite make sense to listen for it.

When a listener L awakens for a new connection it cobbles together the  
plumbing necessary to manage the connection.  That plumbing will  
invoke the methods of an object C responsible for handling the  
connection.  The listener L creates the object P, one for each  
connection, by via the factory object F it was given when L was  
created.  It is the responsibility of C to implement protocol  
appropriate to the connection.

What twisted.internet.stdio.StandardIO provides is a very simple  
protocol for standard IO.

More information about the Twisted-Python mailing list