I'm using Rust w/ Tokio to build a simple TCP chat server. My code functions identically to their chat example here.
However, when using the telnet client on my machine (MacOS 12.6.6) it always echoes back the last line the user entered. I've tried sending various different bytes (IAC WONT ECHO etc.) down the socket but this either breaks and causes and error on the server side or does nothing.
I've noticed the client always defaults to the 'obsolote linemode' but I can't seem to toggle echo with '^E' like the man pages mentions. Switching to character mode stops the echo but I want to keep it in line by line mode.
I'd like the server to not echo by default, if anyone knows how I can accomplish this it would be much appreciated.
The ECHO option actually means remote echo, so if you want the server to not echo, the client have to send
IAC DONT ECHO.There is no option to control local echo, it is determined by the client program depending on the (remote) ECHO option.
Note, that if you turn of ECHO, but WILL GA was already send by the server, the client behaves strangely, but I don't know why: What is the behaviour of GA without ECHO? (telnet) .
Maybe that is the erroneous behaviour you are seeing.
If you want local editing, but also specify echoing, you might need to implement LINEMODE.
(Funny, that I had the exact same idea at the same time.)