flush () will force data to be sent to the OS. The OS can buffer data, as well as the OS on the client. If you want the OS to send data earlier, I suggest you try disabling the Nagle algorithm. socket.setTcpNoDelay (true); However, you will find that the OS / driver options may still introduce some buffering / batch coelesing.
If you look at the Sun JDK 6 java.net.SocketOutputStream, you will see that the flush () method does nothing. This is not guaranteed on all platforms, and may require cleaning ().
source
share