views:

544

answers:

2

Hi,

I'm implementing a simple proof of concept Telnet server in C# and telnet to it via the windows built in telnet client. I echo all non IAC data back to the client. However, I can't figure out how to get backspace/delete to work correctly. I tried several combinations acting on 'BS' from the telnet client:

  • 'BS' (moves cursor back by one but doesn't delete character)
  • 'BS''DEL' (same result as 'BS' only)
  • 'BS''DEL''ESC[3~' (same result)

Can anyone please point me to what's the correct control sequence to backspace and remove the character from the screen?

Thanks,

Tom

+1  A: 

Behavior of delete and backspace are dependent on the terminal emulation of the server. Further, hitting backspace and or delete in the client may or may not send the actual backspace and delete keycodes to the server, depending on what it believes the emulation to be. I don't believe there is a terminal agnostic command for moving back one character and removing the last character. Here's a good discussion of the problem.

Finally, don't use the windows built in telnet client. It sucks. I prefer Van Dyke's SecureCRT, but if you don't want to spend money, PuTTY is a popular free client.

Jherico
Well, as indicated in my post, I'm reacting on the client sending 'BS' (backspace) and tried to reply with different control sequences to achieve the desired behavior. I've read the article you posted and it says to do what I did. I don't want to use SecurCRT or PuTTY for this, which btw show the same behavior.
Tom Frey
Your question leaves unclear how you're determining what's being sent. Are you looking at debug information on the server side or simply relying on windows telnet to send BS when you hit the backspace key?
Jherico
I'm looking at debug information and trace traffic with wireshark
Tom Frey
+1  A: 

I just connected to a Cisco switch and traced how IOS is implementing it. IOS is sending 'BS' 'SPACE' 'BS' on an incoming 'BS' from the client. So, that's how I implemented it now and works great.

Tom Frey