[Twisted-web] Telnet server: Detecting CTRL-<key>,
as happends with CTRL-C
Eloranta, Teuvo (NSN - FI/Tampere)
teuvo.eloranta at nsn.com
Thu Feb 5 05:09:55 EST 2009
Ok, that's exactly what I was after, the character mode.
I'll try make the telnet client switch to character mode with IAC + WONT + LINEMODE
>>I have an application, with Python 2.4 and Twisted 8.2.0.
>>Can I somehow detect e.g. CTRL-J key presses in:
>> class Telnet_simulation(telnet.Telnet)
>> def dataReceived(self, data):
>>(or elsewhere in code)?
>If the `telnet´ above is twisted.protocols.telnet, then you
>to twisted.conch.telnet. If it's twisted.conch.telnet, then you should
>override `applicationDataReceived´, not `dataReceived´ (or use
>one of the
>other mechanisms for hooking into it - subclass and override is one
>approach, but there are others which you can find examples of
>>When sending CTRL-C, the dataReceived() is called
>immeaditely, but when
>>sending some other combinations, the data can be seen only after Enter
>>(telnet_Command is called then) But the CTRL-J is not a
>>it should act same way as CTRL-C.
>Ah, telnet_Command, I guess you are using twisted.protocols.telnet. :)
>Most likely your telnet client is in line editing mode. This means it
>isn't sending data typed in until enter is pressed, so of
>course you can't
>receive it until then. There are telnet negotiation options
>which you can
>use from the server to ask the client to go into character
>mode. You can
>see some code which negotiates about linemode in
>(search for LINEMODE). I'm not sure if LINEMODE is the
>for controlling this behavior (I seem to recall there being
>but I forget which obsoleted which).
>Also, twisted-python at twistedmatrix.com might be a more
>appropriate list for
>this topic, since this is a web-oriented list.
More information about the Twisted-web