Going to ''char-by-char mode''

From: Daniel Koepke (dkoepke@CALIFORNIA.COM)
Date: 05/24/98


Ahh, bloody Hell.  This started off as one of those rare messages
where _I_ ask for help.  I even had a little blurb that said, "If
you're loooking for more stupid Mailer Code(tm) -- look elsewhere (at
least, for the time being)."  However, I solved my problem by the time
I got to the second paragraph.  But it was a real pain in the ass to
figure out, so I'll post it here in case someone is interested.
There's still no Mailer Code(tm), though.

My problem was getting telnet to negotiate with me about turning off
TELOPT_LINEMODE (switching to ''char-by-char mode'').  The thing is
that telnet does not perform negotiation on ports other than 23 by
default.  This is, I suspect, to prevent a nightmare when telneting
into things -- like CircleMUD -- that don't support telnet sending it
a bunch of IACs.  You can force telnet to perform these negotiations
by preceeding the port number with a dash (this seems only to work
from within telnet, and not on the command line) or you can easily
force telnet to switch to ''char-by-char mode'' by doing 'mode char'
from within telnet.  However, this isn't idyllic.  I wanted the server
to be able to control the LINEMODE.

This seemed easy enough when I approached the problem two days ago.  I
figured I could send an IAC WONT LINEMODE and, even though telnet
won't negotiate with me, it'd switch.  However, it didn't.  As it
would turn out, telnet was entirely stubborn about doing nearly
anything to its state for me.  I thought, at first, this might be a
problem with the codes I was sending out to 'telnet' -- but the RFC (I
forget the number, sorry) confirmed that IAC WONT LINEMODE is what the
server should be sending -- and a 'set options' from within telnet
proved that the telnet client was receiving it.  It was just ignoring
my demand.

I then decided the problem was with my code to negotiate with telnet
(I pretty much ignroed everything it sent me -- mostly, telnet is
sending confirmation of the server's demands, so ignoring what it had
to say was only a pecadillo) -- however, 'set options' cast doubt on
this.  Telnet wasn't reporting that it was sending any codes back to
me, and, as far as I could tell, I didn't need to respond to any
telnet messages for what I was trying to do (I wasn't doing any
sub-negotiation if you're wondering).  So, if my code to
interpret/ignore telnet's messages wasn't the problem (thank God --
it's no wonder why the Linux man page for 'telnet' says in the Bugs
section, "The source code is not comprehensible."), I was still left
with telnet being stubborn and, apparently, no problems in either my
code to send the IAC WONT LINEMODE -- nor in my code to discard
whatever telnet would send back (which was nothing at the time, BTW).

The solution came to me when, disgruntled and finally tired of trying
to figure it out for myself, I resolved to just tell players to switch
to ''char-by-char mode'' their own damn self and don't expect the
server to do it for them.  I issued a 'mode char' to make sure
everything worked fine, and then I saw something I had simply
overlooked before.  Telnet sent me an IAC DO SUPRESS_GA before sending
me the LINEMODE stuff.  Curious and somewhat excited, I switched back
to linemode with 'mode line' and watched as it sent me a DONT
SUPRESS_GA before the DO LINEMODE.  This was all I needed to know.

I changed my code to switch to ''char-by-char mode'' to do (note: not
"Circle-ified" [or "Circled" or "Circumscribed"?]),

  void Conn::charMode(void)
  {
    send_iac(WILL, TELOPT_SGA); // send_iac just sends IAC 1st 2nd arg
    send_iac(WONT, TELOPT_LINEMODE);
    send_iac(WONT, TELOPT_ECHO);
    read_func = read_char;
  }

  void Conn::lineMode(void)
  {
    send_iac(WONT, TELOPT_SGA);
    send_iac(WILL, TELOPT_LINEMODE);
    send_iac(WILL, TELOPT_ECHO);
    read_func = read_line;
  }

This can be used for a variety of things.  I'm presently using it only
for auto-detecting ANSI support, but may use it for things such as a
scrollable command history, improved editor, and -- in general -- a
better interface.  Since tintin++ doesn't support the telnet state
switching stuff (I'm pretty sure, anyway), this might be enough
incentive for players to move away from all those stupid clients that
have aliases, auto-repeat, etc.  Wooo ...

-dak : Diana ... ?  <blink>  Diana .... ?!


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST