I'm wondering if there's any way to get telnet to send only a \n
, not a \r\n
.
For example, if one process is listening on a port like this, to print the bytes of any traffic received:
nc -l 1234 | xxd -c 1
Connecting to it from netcat with nc localhost 1234
, and typing "hi[enter]":
0000000: 68 h
0000001: 69 i
0000002: 0a .
Connecting to it from telnet with telnet localhost 1234
, and typing "hi[enter]"
0000000: 68 h
0000001: 69 i
0000002: 0d .
0000003: 0a .
Telnet is sending 0x0d0a instead of 0x0a for the newline. I understand that this is a CRLF as opposed to LF. It also sends the CRLF if I use ^M
or ^J
.
I thought I had found a solution that directly addresses this problem, by using toggle crlf
, but even with this option set, Telnet is always sending the \r\n
. I've also tried this on various telnet clients, so I'm guessing I'm misunderstanding what the toggling is supposed to do.
Any way to send just a \n
through telnet, with enter or otherwise?
Best Answer
You can negotiate binary mode. Once in this mode you cannot leave it. Negotiation means the
telnet
client will send a special byte sequence to the server, which you will have to ignore if you are not implementing the protocol.Subsequent data is sent unchanged, in line mode. Client:
and server
Your
telnet
client may have an option to start off in binary mode, or you can put an entry in~/.telnetrc
You can apply the binary mode independently in each direction, so you might prefer
set outbinary
.