Force telnet client in character mode

I have an application in which I accept a socket connection with a telnet client and expose a simple graphical interface with characters on the keyboard.

The telnet client, at least on Linux, works by default in a "turn-by-turn" mode, so I always need to do ^]mode char manually.

Resetting the corresponding RFCs implies that if my application simply sent IAC DONT LINEMODE (\377\376\042) as soon as the client connects, the client must be forced to character mode. However, this does not matter.

What is the simplest bit of code that will do the job? Perfectly simple string to send. My application can be swallowed by any unwanted client that sends back.

+7
char default telnet
Nov 07 '08 at 19:14
source share
3 answers

Interesting. I was lucky to send

 IAC WILL ECHO IAC WILL SUPPRESS_GO_AHEAD IAC WONT LINEMODE 255 251 1 255 251 3 255 252 34 

IAC WONT LINEMODE seems redundant: my telnet client seems to be in the correct state without it, but I left it for completeness.

+8
Jul 01 '09 at 12:28
source share

What he stands for, he decided.

 // IAC WONT LINEMODE IAC WILL ECHO write(s,"\377\375\042\377\373\001",6); 

gets the remote (at least telnet from Xterm in the Linux box) to the correct state.

+6
Nov 10 '08 at 21:40
source share

Kevin's solution works fine: write(s,"\377\375\042\377\373\001",6);

Although the comment is a bit erroneous. It should say "DO LINEMODE", not "WONT LINEMODE", that is: // IAC DO LINEMODE IAC WILL ECHO

(Source: rfc854 )

0
May 22 '16 at 18:15
source share



All Articles