I've been using twisted for about 36 hours now and have an application put together, but in order to get it working just the way I want it to, I want to force the other end of the telnet connection to go into character-at-a-time mode. I haven't seen any examples of setting IAC options, but perhaps I haven't been looking in the proper places.
Does anyone have any hints?
Bryan
On Thu, 24 Apr 2008 11:54:41 -0700 (PDT), Bryan Schmersal bschmer@yahoo.com wrote:
I've been using twisted for about 36 hours now and have an application put together, but in order to get it working just the way I want it to, I want to force the other end of the telnet connection to go into character-at-a-time mode. I haven't seen any examples of setting IAC options, but perhaps I haven't been looking in the proper places.
Does anyone have any hints?
twisted.conch.telnet.Telnet has four methods for option negotiation: do, dont, will, and wont. These correspond to IAC DO, IAC DONT, IAC WILL, and IAC WONT, respectively. You probably want to do something with the LINEMODE option, but I forget what exactly. Once you enable LINEMODE, you'll probably want to do some subnegotiation about it. Telnet has a requestNegotiate method for this. A quick look at RFC 1184 suggests that what you want is roughly IAC DO LINEMODE and, assuming that succeeds, IAC SB LINEMODE MODE (~EDIT & other) IAC SE. This is easy enough to do with the Telnet class:
d = self.do(LINEMODE) def cbLinemode(ignored): self.requestNegotiate(LINEMODE, LINEMODE_MODE + '\0')
You'll also need an enableRemote implementation which allows LINEMODE to be enabled (it just needs to return True for that option).
Hope this helps, let me know how it turns out. :)
Jean-Paul
On Thu, 24 Apr 2008 15:24:25 -0400, Jean-Paul Calderone exarkun@divmod.com wrote:
[snip]
d = self.do(LINEMODE) def cbLinemode(ignored): self.requestNegotiate(LINEMODE, LINEMODE_MODE + '\0')
Of course, cbLinemode should have been added as a callback to d.
Jean-Paul