• Please review our updated Terms and Rules here

Funny Telnet story ...

mbbrutman

Associate Cat Herder
Staff member
Joined
May 3, 2003
Messages
6,432
So I dusted off my old 'server test' code which some of you might remember - it was as simple server running on my DOS box that you could telnet to and run a few commands. I have used it a few times to test the TCP/IP code under more realistic conditions - it supports 9 simultaneous connections, so if there is a bug it will break the code quickly while juggling all of that work.

Even though one would telnet to the code, it never really supported the telnet protocol. It was just sending raw bytes back and forth. To truly do telnet you have to negotiate line handling options and interpret characters in a specific way.

So I was spending some time today adding telnet support to it. I didn't even get to the telnet specific part yet ... I just wanted to see if I could handle echoing of characters and backspacing. After a few bugs it seemed to work, but wow, the echo was slooooww ... Like hit a key, wait a second, and then get the response. My typing was far far faster then what the poor machine could keep up with.

So now I'm scratching my head wondering what I did wrong. The 386-40 can push 450KB/sec through the wire with my TCP/IP code when doing a file transfer, but it was having a delay of a second on each character it was echoing? I was thinking 'something smells really bad here.'

After about 40 minutes I figured it out. I wasn't using the 'Push' bit on the TCP/IP packets I was using to echo the characters. Without that bit being set the TCP/IP stack on Windows was trying to batch up a few characters before giving the telnet app something to read. After about a second or so it was timing out and giving back my echoed characters as a batch, not one at a time as one would like.

Simple fix, but it caused a little worry. I guess you had to be there. :)
 
I've got Telnet!

I've got Telnet!

So tonight I hacked in some rudimentary telnet support ...

  • The server tells the client that it will echo chars
  • Backspace is correctly handled.
  • The user can't backspace if they are at the beginning of a line
  • Additional chars past the edge of the allowable input buffer won't be echoed or recorded.
  • The server can query the client to figure out the terminal type. (Cute, but not used at the moment)
It's some awful crappy code .. there is a lot of memory movement going on and I'm sure I've got some buffer processing bugs, but it worked well enough for tonight. Tested telnet clients include Windows 2000 command line, Windows XP command line, and Putty running on Windows.

Why bother with all of this? Because you can't have a telnet BBS without telnet support. And I'm one step closer now. :) Expect to be able to telnet directly into my PCjr to see the sample server in about a week or so.
 
Back
Top