[Twisted-Python] RE: [Python-Twisted] How to write a simple telnet client?

I played around with your code at http://twistedmatrix.com/pipermail/twisted-python/2005-August/011115.html, even if I don't understand polish. ;-) I didn't expect that one must handle control codes (your function reponseFunct), I expected the protocol to handle that for me, but anyway, that was no problem (i.e. you solved it before). And with your code I could even switch off the echo (your next thread). What I don't understand is how to 'inject' some commands and collect their result. What you tried in your "command" function in __main__ can't work, because the protocol has no transport. I don't understand how to get at the Factory's actual protocol instance and its transport. I could 'hardcode' a list of commands in my protocol class, but that would make no sense... Probably I shouldn't use a ClientFactory but something else. Best regards, Henning Hraban Ramm Südkurier Medienhaus / MediaPro Support/Admin/Development Dept.

On Fri, 23 Sep 2005 19:38:11 +0200, henning.ramm@mediapro-gmbh.de wrote:
You don't actually have to do this. You can implement iac_DO, iac_DONT, iac_WILL, and iac_WONT to handle feature negotiation. You can also use twisted.conch.telnet, which presents a slightly more complete API for feature negotiation.
Factory's don't have protocol instances, in general. A factory is responsible for creating between zero and an unlimited number of instances of a protocol, as they are demanded by established connections. Protocol.connectionMade is provided as a hook for application-level logic. You may want to send your commands from that method. When it is invoked, you will have a transport. Jp

On Fri, 23 Sep 2005 19:38:11 +0200, henning.ramm@mediapro-gmbh.de wrote:
You don't actually have to do this. You can implement iac_DO, iac_DONT, iac_WILL, and iac_WONT to handle feature negotiation. You can also use twisted.conch.telnet, which presents a slightly more complete API for feature negotiation.
Factory's don't have protocol instances, in general. A factory is responsible for creating between zero and an unlimited number of instances of a protocol, as they are demanded by established connections. Protocol.connectionMade is provided as a hook for application-level logic. You may want to send your commands from that method. When it is invoked, you will have a transport. Jp
participants (2)
-
Henning.Ramm@mediapro-gmbh.de
-
Jp Calderone