Search code examples
socketstelnet

Why does telnet send data only on a Enter?


I was playing around with Java sockets and telnet seemed like a good program to simulate a tcp client.

What i don't understand is why does telnet send data only on a enter? I am not looking for hacks to make it send the data immediately(as that is available ( Send data over telnet without pressing enter)) but i want to understand the internal working / design of telnet for which this seemed like the natural fit.


Solution

  • It's an implementation choice.

    Basically, with both TCP and UDP you can buffer as much data as you want before sending it out. The target is to maximize payload size so you don't send a single packet for each key you type, something that you can easily achieve with a customized Java telnet client that flush()es a socket on each character.

    Telnet was born as a remote shell client, and since a normal system shell processes text lines, implementors have found it reasonable to wait for the user to type ENTER before flushing the data to the server, which will stand by for carriage return if received a partial line