Reputation:
I have an application where I accept a socket connection from a telnet client and put up a simple, keyboard driven character GUI.
The telnet client, at least on Linux, defaults into line-at-a-time mode, so I always have to do ^]mode char
manually.
A skim of the relevant RFCs suggests that if my application simply sent the characters IAC DONT LINEMODE (\377\376\042)
as soon as the client connects, the client should be forced into character mode. However, it doesn't make any difference.
What's the simplest bit of code that would do the job? Ideally just a string to be sent. My application can absorb whatever junk the client sends back.
Upvotes: 15
Views: 20042
Reputation: 167
LINEMODE is not the same as old line-by-line mode. If nothing is negotiated, the connection defaults to "old line-by-line mode". You want to enable character mode, which the server can do by sending IAC WILL GA IAC WILL ECHO
. LINEMODE is another option, which kind of combines character mode with local echo and also specifies, that you are able to negotiate the suboptions of the LINEMODE.
Upvotes: 0
Reputation: 31
Kevin's solution works great:
write(s,"\377\375\042\377\373\001",6);
Although the comment is slightly wrong. It should say "DO LINEMODE", not "WONT LINEMODE", ie:
// IAC DO LINEMODE IAC WILL ECHO
(Source: rfc854)
Upvotes: 3
Reputation:
For what it's worth, solved it myself.
// IAC WONT LINEMODE IAC WILL ECHO
write(s,"\377\375\042\377\373\001",6);
gets the remote (at least telnet from an Xterm on a Linux box) into the right state.
Upvotes: 8
Reputation:
Interesting. I had more luck sending
IAC WILL ECHO IAC WILL SUPPRESS_GO_AHEAD IAC WONT LINEMODE
255 251 1 255 251 3 255 252 34
The IAC WONT LINEMODE seems to be redundant: my telnet client seems to get to the right state without it, but I left it in for completeness.
Upvotes: 12