I am using apache.commons.net.telnet.
I have char[] array. I am calling TelnetClient.getOutputStream().write(array[i]).
I expected that my data will be sent by one character at a time, but Wireshark shows that first character is sent alone, and remaining characters are sent together.
Why do I get this situation and how can I send my data character by character?
OK. Here is the correct answer. To send the data as fast as possible, do the following:
Call setTcpNoDelay(true) on your output stream.
Call write with your entire array. You should NEWER EVER write one byte at a time. Writing the entire array at the same time will be much faster.
Call flush() after your write.
This is the fastest way to send the data, and it is also the way which will create the least latency. That is: Sending the bytes one at a time will NOT ensure that the server will receive them any faster.
Sending the data one byte at a time will slow you down, not speed things up.